在viewdidload方法中切换视图控制器
我正在开发一个 iPhone 应用程序,因为我想通过检查用户默认值来切换视图控制器。所以我做了以下操作:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"keyString"] != nil) {
nextViewController *redirectView = [[nextViewController alloc] initWithNibName:@"nextViewController" bundle:[NSBundle mainBundle]];
self.nextView = redirectView;
[self presentModalViewController:self.nextView animated:YES];
} else {
[defaults setObject:@"newValue" forKey:@"keyString"];
}
它不起作用..这是正确的方法吗???如果没有的话谁能告诉我该怎么做..
I am developing one iphone application in that i want to switch view controller by checking userdefaults. so i did the following:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"keyString"] != nil) {
nextViewController *redirectView = [[nextViewController alloc] initWithNibName:@"nextViewController" bundle:[NSBundle mainBundle]];
self.nextView = redirectView;
[self presentModalViewController:self.nextView animated:YES];
} else {
[defaults setObject:@"newValue" forKey:@"keyString"];
}
Its not working.. Is this the right way??? If not can anyone tell me how to do that..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不要将redirectView分配给self.nextView。直接这样传过去
Dont assign redirectView to self.nextView. Pass it directly like this
添加该行
而不是
Add the line
instead of
}
}