ios - 警告 : Attempt to present ModalTableViewController on MainTableViewController which is already presenting (null)

标签 ios cocoa-touch popover

我的弹出窗口有问题。如果我点击一个单元格,我将加载一个弹出窗口以选择更多详细信息。一切正常,但当我再次按下手机时,每次都会收到以下消息:

警告:尝试在已经呈现的 MainTableViewController 上呈现 ModalTableViewController ......(空)

如果我点击另一个单元格,我将不会收到此警告。仅当再次点击同一行时。

我尝试了很多东西,但我无法解决这个问题。我像这样加载我的弹出窗口:

var popover: UIPopoverController!
var popoverContent: ModalTableViewController!

然后点击我的手机:

popoverContent = self.storyboard.instantiateViewControllerWithIdentifier("ModalTableViewController") as ModalTableViewController

popoverContent.selectedQuestionID = indexPath!.row               
popover = UIPopoverController(contentViewController: popoverContent)
popover.delegate = self

popover.presentPopoverFromRect(currentCell.LabelCellTitle.frame, inView: currentCell.LabelCellTitle.superview, permittedArrowDirections: UIPopoverArrowDirection.Left, animated: true)

并解雇

func popoverControllerDidDismissPopover(popoverController: UIPopoverController!) {

    popover.dismissPopoverAnimated(false) // just to check

    self.popover = nil
    self.popoverContent = nil

}

有什么想法吗?

编辑:

如果我检查:

if(self.popoverContent == nil) {

在打开它之前,当我再次点击同一个单元格时,我会发现它不是零。

再次编辑:

如果我使用稍微不同的设置创建它,我会遇到同样的问题:

自定义 1x1px 按钮。将 popover 与 segue 连接起来。在单元格上点击移动按钮到单元格并打开弹出窗口。

所以没有打开弹窗的代码,只有 Storyboard编辑器。

即使我再次点击相同的弹出窗口,我(有时)也会收到相同的错误消息。

最佳答案

我遇到这个问题是因为我试图从内部执行 segue/present:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

我把它改成:

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

它修复了它!

关于ios - 警告 : Attempt to present ModalTableViewController on MainTableViewController which is already presenting (null),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25213152/

相关文章:

jquery - twitter bootstrap 模态,内部有弹出窗口

ios - 使用解码对象(: forKey:) to decode an object that conforms to a protocol

ios - 连接 Outlet Collection 故障

iOS - 具有抑郁状态的自定义按钮

未调用 SwiftUI Popover dismissHandler

javascript - 弹出窗口的数量会影响页面加载速度吗?

ios - 您可以使用 iOS 应用程序发送弹出通知吗?

ios - 连接两个 Storyboard

objective-c - 多任务iPhone SDK uibackgroundmodes无法与音频一起使用吗?

iphone - 从应用程序将图片/图像存储在 SQLite DB 中是个好主意吗?