Chi*_*isx 16 objective-c ios ios7
编辑:当解决这个问题时,我发现从你的方法开始UITabBarController,然后通过你AppDelegate.m的didFinishLaunchingWithOptions:方法执行登录验证要容易得多.
问题:
此代码application didFinishLaunchingWithOptions:位于AppDelegate.m中的方法中
if([result isEqualToString: @"log"])
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"TabBarControl"];
[(UINavigationController*)self.window.rootViewController pushViewController:ivc animated:NO];
NSLog(@"It's hitting log");
}
Run Code Online (Sandbox Code Playgroud)
它只是为登录的用户提供HTTP响应,并将它们带到我的TabBarController.问题是它使用推送而不是模态转换来显示页面.由于在iOS7中不推荐使用presentModalViewController方法,因此如何以编程方式强制进行模式演示?
Und*_*ndo 30
旧presentViewController:animated:方法已被弃用,我们需要使用presentViewController:animated:completion.您现在只需要completion在方法中添加一个参数 - 这应该有效:
if([result isEqualToString: @"log"])
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"TabBarControl"];
[(UINavigationController*)self.window.rootViewController presentViewController:ivc animated:NO completion:nil];
NSLog(@"It's hitting log");
}
Run Code Online (Sandbox Code Playgroud)
文档是一个很好的起点 - 文档UIViewController presentViewController:animated可以准确地告诉您需要知道的内容:
presentModalViewController:动画:
呈现由给定视图控制器管理给用户的模态视图.(在iOS 6.0中不推荐使用.请
presentViewController:animated:completion:改用.)Run Code Online (Sandbox Code Playgroud)- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
Sur*_*gch 21
由于接受的答案是在Objective-C中,因此您将在Swift中执行此操作.但是,与接受的答案不同,我的答案没有引用导航控制器.
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let secondViewController = storyboard.instantiateViewController(withIdentifier: "secondViewController") as! SecondViewController
self.present(secondViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
根据需要更改故事板名称,视图控制器和ID.
另请参见如何以编程方式关闭视图控制器.
| 归档时间: |
|
| 查看次数: |
43364 次 |
| 最近记录: |