gpt4 book ai didi

ios - 使用 iPhone 设备测试时 UIAlertController 错误(线程 1 : EXC_BAD_ACCESS) iOs SWIFT

转载 作者:行者123 更新时间:2023-11-30 14:08:41 25 4
gpt4 key购买 nike

这是一个奇怪且令人沮丧的问题,因为当我要求他测试这些代码时,这些代码在我 friend 的计算机和 iPhone 设备上工作,但在我的计算机和 iPhone 4 上不起作用。该错误称为“线程 1:EXC_BAD_ACCESS” (code=1,address=0x10)"并且它出现在 var 警报声明中。当我在测试期间单击 iPhone 设备上的按钮后,就会发生这种情况。

@IBAction func button(sender: AnyObject) {

self.showRateMe()

}


//MARK: - Private Methods
func showRateMe()
{


var alert = UIAlertController(title: "Rate Us", message: "Thanks for
using the app! We value your feedback. Please take a few seconds to
review our app to make it better", preferredStyle:
UIAlertControllerStyle.Alert)


alert.addAction(UIAlertAction(title: "Hello!", style: UIAlertActionStyle.Default, handler:
{ alertAction in
self.openReviewPage()
alert.dismissViewControllerAnimated(true, completion: nil)
}))
alert.addAction(UIAlertAction(title: "No Thanks", style: UIAlertActionStyle.Default, handler: { alertAction in

alert.dismissViewControllerAnimated(true, completion: nil)
}))


/*
alert.addAction(UIAlertAction(title: "Maybe Later", style: UIAlertActionStyle.Default, handler: { alertAction in
alert.dismissViewControllerAnimated(true, completion: nil)
}))
*/

self.presentViewController(alert, animated: true, completion: nil)

}

最佳答案

我相信你的问题是你的警报消息中有 2 个硬返回,并且编译器不高兴。我剪切并粘贴了您的代码,删除了硬回车,它按预期工作。干杯。

关于ios - 使用 iPhone 设备测试时 UIAlertController 错误(线程 1 : EXC_BAD_ACCESS) iOs SWIFT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32020667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com