繁体   English   中英

从appdelegate呈现视图控制器

[英]Present a view controller from appdelegate

我没有使用LaunchScreen.xib。 我正在将情节提要用于启动画面。 我正在调用API来获取初始图像。 我正在应用程序委托中执行此操作。 我可以在视图控制器上显示图像,但是一旦显示图像,便无法转到其他控制器。

这是我在AppDelegate中拥有的东西:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{


self.window.frame=CGRectMake(0, 200, 100,30);

[self.window addSubview:[self convertImage: image]];

//upto here everything is fine

//now i am trying to wait for 3 seconds and call another view controller

sleep(3);

ViewController *login=[[ViewController alloc]initWithNibName:@"Login" bundle:nil];
[self presentviewcontroller:....]; // not able to present another controller

}

您可以使用:

[[self window].rootViewController presentViewController:login animated:YES completion:nil];

迅捷3

self.window?.rootViewController?.present(viewController, animated: true, completion: nil)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM