Sag*_*ari 2 iphone xcode nsnotifications uiviewcontroller uinavigationcontroller
我见过iPhone MP-movie player的示例应用程序 - 控制器.
他们在示例代码中添加了通知.
// Register to receive a notification that the movie is now in memory and ready to play
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,当MPMoviePlayerController完成加载时,它会调用moviePreloadDidFinish方法.
同样,我想在用户按下导航栏上的按钮(通过导航控制器返回上一个视图控制器)时触发一个方法.
我不知道如何为此添加通知.
将您自己的自定义后退按钮放在navigationItem:
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithImage:yourImage style:UIBarButtonItemStyleBordered target:self action:@selector(goBack)];
self.navigationItem.leftBarButtonItem = btn;
[btn release];
Run Code Online (Sandbox Code Playgroud)
在goBackviewController 的方法中,你将放置你需要的任何代码,然后弹出viewController:
- (void)goBack {
/* your code here */
[self.view.navigationController popToRootViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5815 次 |
| 最近记录: |