0
我現在使用我的導航項創建退出按鈕(左側導航項)。在創建導航視圖控制器中嵌入的視圖控制器時,似乎我們無法通過使用popViewControllerAnimated和dismissViewControllerAnimated來退出應用程序。請告訴我該怎麼辦?我的後退按鈕無法退出我的應用程序
下面是我的嵌入查看控制器代碼
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
navigationBar = self.navigationController.navigationBar;
[navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
[UIFont fontWithName:@"TitilliumText22L-Medium" size:22.0], NSFontAttributeName,
nil] ];
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"TEST SSS"];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
[button setImage:[UIImage imageNamed:@"menu_back.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *buttonItemA = [[UIBarButtonItem alloc] initWithCustomView:button];
navigationItem.leftBarButtonItem = buttonItemA;
UIButton *buttonA = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 88, 30)];
[buttonA setImage:[UIImage imageNamed:@"sss.png"] forState:UIControlStateNormal];
UIBarButtonItem *buttonItemB = [[UIBarButtonItem alloc] initWithCustomView:buttonA];
navigationItem.rightBarButtonItem = buttonItemB;
[navigationBar pushNavigationItem:navigationItem animated:NO];
}
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)buttonClicked:(id)sender {
NSLog(@"ssd finish");
[self.navigationController popViewControllerAnimated:YES|NO];
}
@end
閱讀[本](http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application),蘋果不建議手動觸發出口雖然,並退出應用程序不會解僱你的根VC – Tj3n
即使這是唯一的一個根視圖? –
是的,解僱你的VC只是解僱黑色的窗口,我認爲,不是終止應用程序 – Tj3n