gpt4 book ai didi

iphone - 推送 View 而不是从基于单一 View 的应用程序推送 UIViewController

转载 作者:行者123 更新时间:2023-12-03 20:30:59 25 4
gpt4 key购买 nike

我选择项目模板作为“单一 View ”。我试图在按钮单击上推送详细 View (UIViewController)。按钮操作正确触发并执行代码[self navigatingController]推送......我的代码是:

MapDetailViewController *mapDetailViewController = [[MapDetailViewController alloc] init];
[self.navigationController pushViewController:mapDetailViewController animated:YES];
NSLog(@"self.navigation is as %@",self.navigationController);

self.navigationController 为 null。所以我尝试分配 init 类型为 Navigation Controller 的局部变量,并且该变量也可以为非 null(某些十六进制值),但我仍然无法推送 mapDetailView。
我在想的是,我选择了错误的模板(基于 View )。我应该选择基于导航的(主从)。下面自动生成的代码是应用程序委托(delegate):

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;

是否应该对导航 Controller 进行一些更改?
有什么建议吗?

最佳答案

你的问题是你甚至没有导航 Controller 来进行推送。将您的代码更改为:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}

关于iphone - 推送 View 而不是从基于单一 View 的应用程序推送 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10452991/

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