我如何从按下的后退按钮弹出视图,我从以前的视图控制器中传递了以下代码。谢谢
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:nil action:nil];发布于 2010-05-16 14:23:11
不需要手动添加后退按钮。
但是,如果您确实需要那个自定义按钮来弹出视图控制器,您可以制作一个自定义消息。
-(void)popViewControllerWithAnimation {
[self.navigationController popViewControllerAnimated:YES];
}
...
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:self action:@selector(popViewControllerWithAnimation)];或者创建一个NSInvocation。
NSInvocation* invoc = [NSInvocation invocationWithMethodSignature:
[self.navigationController methodSignatureForSelector:@selector(popViewControllerAnimated:)]];
// watch out for memory management issues: you may need to -retain invoc.
[invoc setTarget:self.navigationController];
[invoc setSelector:@selector(popViewControllerAnimated:)];
BOOL yes = YES;
[invoc setArgument:&yes atIndex:2];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:invoc action:@selector(invoke)];https://stackoverflow.com/questions/2842464
复制相似问题