【问题标题】:Present a view controller from appdelegate从 appdelegate 展示一个视图控制器
【发布时间】:2015-02-11 21:23:37
【问题描述】:

我没有使用 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

}

【问题讨论】:

    标签: ios objective-c appdelegate


    【解决方案1】:

    你可以使用:

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

    【讨论】:

      【解决方案2】:

      斯威夫特 3

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

      【讨论】:

      • 如何使用 appdelegate 中的 self?
      猜你喜欢
      • 1970-01-01
      • 2017-04-11
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      • 2017-10-25
      • 2017-10-23
      • 2015-10-20
      • 2012-06-25
      相关资源
      最近更新 更多