1

我有一个名为“takeAction”的模态视图控制器。当模态视图控制器呈现给用户时,我试图在 takeAction 中加载 UIBarButtonItem。因此, UIBarButtonItem 与模式视图控制器的内容是异步的。

但是按钮根本不存在。我怎样才能解决这个问题?

代码:

AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navController = [delegate navController];
[navController presentModalViewController: takeAction animated:YES];

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:UIBarButtonItemStyleDone
target:self action:@selector(done)];

takeAction.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];
4

1 回答 1

0
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:@selector(done)];

takeAction.navigationItem.rightBarButtonItem = doneButton ;
[doneButton release];

将上面的行放到这一行:

UINavigationController *navController = [delegate navController]; 
[navController presentModalViewController: takeAction animated:YES];
于 2010-11-25T06:33:44.723 回答