[问题] 两个UIAlertController时会闪退

楼主: KeyBoardKill (✩键✩盘✩戮✩)   2018-06-08 15:31:38
各位好,我是学Swift不到一个礼拜的新手,今天尝试更改别人的程式码,我尝试将Alert
button 增加成两个,在iPhone上是正常的,但iPad会闪退,上网查询是因为内存位址
导致...但写的看不懂,我应该怎么去解决它呢?感谢指点
https://ideone.com/yZyAId
这是我其中的Code & alert log
2018-06-08 15:12:17.607567+0800 QRCodeReader[519:108687] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-06-08 15:12:17.610165+0800 QRCodeReader[519:108687] [MC] Reading from public effective user settings.
2018-06-08 15:12:25.936288+0800 QRCodeReader[519:108687] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x142055000>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a
sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
*** First throw call stack:
(0x182caed8c 0x181e685ec 0x18d4edef4 0x18cd44d58 0x18cd42f2c 0x18cca2884 0x18cc98958 0x18cb7d51c 0x182c56910 0x182c54238 0x182c54884 0x182b74da8 0x184b59020 0x18cb91758 0x100b79678 0x182605fc0)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
作者: Blueshiva (龙野南云)   2018-06-08 15:44:00
*** Terminating app 那行英文看懂就好了...
作者: tentenlee (天天)   2018-06-08 16:57:00
另外 其实现在不用canOpen 能开他自己会开 不会crash了以前要加是因为不能开 你去开 他就直接crash了
作者: shinrenpan (iOS5)   2018-06-08 22:43:00
UIAlertController 在iPhone 与 iPad 下 present 的方式有所不同.

Links booklink

Contact Us: admin [ a t ] ucptt.com