最终通过调试,看log
2016-07-07 14:34:13.851 [Verbose] [main] [TaskManagementViewController.swift:417] tableView(_:didSelectRowAtIndexPath:) > after self.presentViewController(selectItemVC 2016-07-07 14:34:15.526 [Verbose] [main] [SelectItemViewController.swift:102] tableView(_:cellForRowAtIndexPath:) > tableView=<UITableView: 0x7a250800; frame = (15 152; 290 264); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x79860280>; layer = <CALayer: 0x79775300>; contentOffset: {0, 0}; contentSize: {290, 264}>, indexPath=<NSIndexPath: 0x797b34d0> {length = 2, path = 0 – 0} |
而发现代码:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){ gLog.verbose(“tableView=\(tableView), indexPath=\(indexPath)”) 。。。 gLog.verbose(“before let selectItemVC = SelectItemViewController”) let selectItemVC = SelectItemViewController(curSelectIdx: self.selectTaskType, selectItemList: items, completionHadler: self.getTeskType(_:)) gLog.verbose(“selectItemVC=\(selectItemVC)”) selectItemVC.modalPresentationStyle = .Custom // dispatchMain_async({ gLog.verbose(“before self.presentViewController(selectItemVC”) self.presentViewController(selectItemVC, animated: true, completion: nil) // }) gLog.verbose(“after self.presentViewController(selectItemVC”) |
之后,加载并显示另外一个tableview,第一次会很慢
swift tableview presentViewController another tableiview slow
ios – ViewController presented slowly in didSelectRowAtIndexPath – Stack Overflow
ios – presentViewController:animated:YES view will not appear until user taps again – Stack Overflow
ios – UITableView and presentViewController takes 2 clicks to display – Stack Overflow
ios – Delay in presenting a modal view controller – Stack Overflow
Developer Forums: Very long delay (20 seconds) to bring up modal view in iOS7, instant in iOS 6
[总结]
在tableview中的didSelectRowAtIndexPath去用presentViewController另外一个viewcontroller
由于iOS自己的bug,有时候显示很慢,有时候又很正常的及时显示
没有彻底的解决办法,只有wordkaround:
dispatch_async(dispatch_get_main_queue()) { self.presentViewController(selectItemVC, animated: true, completion: nil) } |
即可。
转载请注明:在路上 » [已解决]swift中tableview中modalPresentationStyle为Custom去presentViewController显示另外一个tableview结果第一次加载显示时很慢