may*_*308 27 uitableview ios swift
我的应用程序的一个规格是,在点击tableView单元格时,用户将被重定向到与单元格关联的网站.这是代码:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if let url = NSURL(string: appdelegate.studentInfo[indexPath.row].url) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
UIApplication.sharedApplication().openURL(url)
}
else {
let alert = UIAlertController(title: "Invalid URL", message: "Cannot open URL because it is invalid.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
在我第一次点击时,URL就像它应该的那样打开.但是,从Safari返回应用程序并触摸另一个单元格会导致以下错误,尽管该应用程序仍然可以正常工作:
快照未呈现的视图会导致空快照.确保在屏幕更新后快照或快照之前至少渲染了一次视图.
有什么办法可以避免这个错误吗?或者这是一个错误?
我已经尝试过dispatch_async块,但它没有解决问题.
Sal*_*iom 42
它可能与我的问题不一样,但我刚刚在日志中解决了相同的警告.
我在UIAlertController
iPad上显示一个actionSheet popover,每当我试图显示警报控制器时,我连续8次发出相同的警告.
为了使警告消失,我所要做的就是布局警报控制器视图,如下面的代码所示:
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
...
alertController.view.layoutIfNeeded() //avoid Snapshotting error
self.presentViewController(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我希望这可以帮助您或任何其他人发出同样的警告.
归档时间: |
|
查看次数: |
19055 次 |
最近记录: |