簡體   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