ios - 在 viewdidappear 中快速呈现模态

标签 ios swift

一般来说,我是 swift 和 ios 编程的新手。我正在尝试在我的应用程序首次加载时显示模态视图。我遇到的问题是我的模式一遍又一遍地出现。不确定我哪里出错了。

红利问题:最终我希望只在用户第一次打开应用时发生这种情况。

class ViewController: UIViewController {

    var introModalDidDisplay = false

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        showIntroModal()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func showIntroModal() {
        if (!introModalDidDisplay) {
            println(introModalDidDisplay)
            introModalDidDisplay = true
            let intro = self.storyboard?.instantiateViewControllerWithIdentifier("introModal") as IntroModalViewController
            intro.modalPresentationStyle = UIModalPresentationStyle.FormSheet
            self.presentViewController(intro, animated: true, completion: nil)
        }
    }
}

最佳答案

找到了。我的“介绍”类正在扩展 ViewController 而不是 UIViewController...显然这很糟糕。谢谢您的帮助!对不起,我的胡思乱想。

关于ios - 在 viewdidappear 中快速呈现模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26389606/

相关文章:

iphone - Trigger.io 无法指向证书。/usr/bin/codesign : iPhone Developer: no identity found

ios - 使用reverseGeocodeLocation:设置地址字符串,然后从方法返回

ios - (Swift)如何通过触摸按钮更改 pageviewcontroller 中的 View

ios - 在 Swift 中使用 TWTRShareEmailViewController (Fabric Twitter SDK) 请求用户 Twitter 邮件

ios - 如何使用自定义单元格中的按钮获取自定义 UITableViewCell 的行,该按钮将发送到 deleteRowsAtIndexPaths

ios - 我可以在 semaphore.wait() 主线程上调用吗?

ios - YouTube iframe API seekTo 在 iOS 6/iPad 3 上不工作

swift - 从闭包中获取值(value)并快速添加到 numberOfRowsInSection

ios - 未显示 swift xcode 堆栈 View 选项

swift - 创建值之间的距离大于 1 的 CountableClosedRange<Int> 的最快方法