作者KeyBoardKill (✩键✩盘✩戮✩)
看板MacDev
标题[问题] 两个UIAlertController时会闪退
时间Fri Jun 8 15:31:38 2018
各位好,我是学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)
--
◢ ◣
● █
≡◥◣ ◢
◣
】 。 \。【 这个板需要更高竿的酸民
● //﹀\\● ◥
◤
】 ╰═╯【 ◤
◢◥ ◤◣
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 180.217.187.172
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MacDev/M.1528443144.A.C80.html
※ 编辑: KeyBoardKill (180.217.187.172), 06/08/2018 15:41:14
1F:→ Blueshiva: *** Terminating app 那行英文看懂就好了... 06/08 15:44
谢谢指点^^我使用了popoverPresentationController来解决
※ 编辑: KeyBoardKill (180.217.187.172), 06/08/2018 16:01:06
2F:推 tentenlee: 另外 其实现在不用canOpen 能开他自己会开 不会crash了 06/08 16:57
3F:→ tentenlee: 以前要加是因为不能开 你去开 他就直接crash了 06/08 16:58
4F:→ shinrenpan: UIAlertController 在iPhone 与 iPad 下 present 的 06/08 22:43
5F:→ shinrenpan: 方式有所不同. 06/08 22:43