开发者

Problem with button in navigationItem

i create a tableViewController in this way:

myTableViewController *tableController = [[[myTableViewController alloc] initWithNibName:@"myTableViewController" bundle:nil] autorelease];

// Setto il pulsante per tornare indietro
UIBarButtonItem *tempButton = [[UIBarButtonItem alloc] init];
tempButton.title = @"Back";
self.navigationItem.backBarButtonItem = tempButton;
[tempButton release];

[self.navigationController pushViewController:tableController animated:NO];

then in the table开发者_C百科viewcontroller, making self.navigationItem.BackBarButtonItem.Title = ... it does'nt happen anything, i've seen that the backbutton is = null.

How can i do? i've tried cutting off the creation of button in first code but it's the same.


Try using a different init method for UIBarButtonItem:

                    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] 
                                               initWithTitle:@"Back"
                                               style:UIBarButtonItemStyleDone 
                                               target:nil 
                                               action:nil];


Firstly set the action for back button.

  1. Initialization button action when an object is created

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil];

  1. Directly add target after allocating object for button

[backButton addTarget:nil action:nil];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜