开发者

how to add custom bar button item to navigation bar in AddressBookUI application like edit in place of cancel

开发者 https://www.devze.com 2023-03-15 17:21 出处:网络
I can not understandwhy navigation bar is not going to add any buttonother than cancel buttonin Following code

I can not understand why navigation bar is not going to add any button other than cancel button in Following code this kind of thing done in Viber application so it is possible

 ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController     alloc] init];
picker.navigationBar.tintColor=[UIColor colorWi开发者_高级运维thRed:91.0/256.0 green:72.0/256.0 blue:110.0/256.0 alpha:1.0];
//picker.navigationController.navigationBar.topItem.rightBarButtonItem = nil;
[picker.navigationBar setHidden:NO];
picker.peoplePickerDelegate = self;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], 
                           [NSNumber numberWithInt:kABPersonEmailProperty],
                           [NSNumber numberWithInt:kABPersonBirthdayProperty], nil];

//picker.navigationBarHidden=TRUE;
picker.displayedProperties = displayedItems;
//UIBarButtonItem *addbutton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(AddContact)];          
   //   picker.navigationController.navigationBar.topItem.rightBarButtonItem = addbutton;

[self presentModalViewController:picker animated:NO];
[picker release];
//[addbutton release];

can anybody help please


refer this article it demonstrates how to add custom button on ABPeoplePickerNavigationController


i can show you how to add custom button to navigation bar. Use this code if this is helpful,

UIImage *buttonImage = [UIImage imageNamed:@"Done.png"];

    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    [aButton setImage:buttonImage forState:UIControlStateNormal];

    aButton.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);

    UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton];

    [aButtonaddTarget:selfaction:@selector(navigatehome)forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.rightBarButtonItem = aBarButtonItem;

    [aBarButtonItem release];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号