UIBarButtonItem Not shown
I have a modal view controller called "takeAction". I am trying to load a UIBarButtonItem in takeAction when the modal view controller is presented to the user. So that, the UIBarButtonItem is asynchronous to the content of the modal view controller.
But the button is not present at all. How can I fix this?
Code:
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navController = [delegate navController];
[navController presentModalViewController: takeAction animated:YES];
UIBarButton开发者_StackOverflow社区Item *doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonItemStyleDone
target:self action:@selector(done)];
takeAction.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:@selector(done)];
takeAction.navigationItem.rightBarButtonItem = doneButton ;
[doneButton release];
Put the lines above to this line:
UINavigationController *navController = [delegate navController];
[navController presentModalViewController: takeAction animated:YES];
精彩评论