我有一个名为“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];