gpt4 book ai didi

ios - 我的后退按钮无法退出我的应用程序

转载 作者:行者123 更新时间:2023-11-29 01:21:37 25 4
gpt4 key购买 nike

我现在正在使用我的导航项来创建退出按钮(左侧导航项)。在创建嵌入导航 View Controller 的 View Controller 时,似乎我们无法使用 popViewControllerAnimated 和 dismissViewControllerAnimated 退出应用程序。你能告诉我该怎么做吗?

下面是我的嵌入 View Controller 的代码

#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

最佳答案

请阅读此链接上的文档,Apple Q&A Link for quit iOS app

这应该可以回答您的问题:-

转到您的 info.plist 并检查 key “应用程序不在后台运行”并将其设置为:-“真”然后当用户按下主页按钮时,应用程序完全退出。

或者如链接所建议的那样弹出一个警告,以便用户知道如何退出应用程序。

关于ios - 我的后退按钮无法退出我的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34522677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com