【问题标题】:how to use 'presentViewController' with cover View and main page如何在封面视图和主页中使用“presentViewController”
【发布时间】:2015-10-12 13:37:23
【问题描述】:

很多应用程序,他们有封面视图,如 facebook、wechat... 但是当我尝试使用 presentViewController 时,让封面出现在主页上,仍然在封面中。以下是我的代码:

var window: UIWindow?
var coverVC:CoverView?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.backgroundColor = UIColor.lightGrayColor()
        coverVC = ViewController()
        coverVC?.refresh(window!.frame)
        window!.makeKeyAndVisible()
        return true
    }

概览

class CoverView: UIViewController {

func refresh(frame:CGRect){
    self.view.frame = frame
    self.view.backgroundColor = UIColor.whiteColor()

    var mainVC:mainView = mainView()
    mainVC.refresh(frame)

    self.dismissViewControllerAnimated(false, completion: nil)

    self.presentViewController(mainVC, animated: false, completion: nil)       
   }
}

主视图:

class mainView: UIViewController {

        func refresh(frame:CGRect){
             self.view.frame = frame
             self.view.backgroundColor = UIColor.blueColor()
        }
}

也许可以使用其他简单的方法来实现目标,没关系。 否则,请不要使用“UInavigationcontroller”,我知道它可以呈现视图,但我不希望该栏在封面视图中,谢谢。

【问题讨论】:

    标签: swift ios9 presentviewcontroller


    【解决方案1】:

    我找到了正确的封面/登录视图,它被称为 SplashScreen。 在 xcode 9 中,您可以在 [TARGETS]>[APP 图标和启动图像] (Image) 找到。(过去的版本,您需要在 plist 文件中添加“启动图像”。)

    否则,如果您不想使用此视图,只需删除“LaunchScreen”即可。

    【讨论】:

      猜你喜欢
      • 2014-02-20
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 2019-01-11
      • 1970-01-01
      相关资源
      最近更新 更多