小编Ste*_*any的帖子

ActionSheet无法使用iPad

我在我的应用程序中使用ActionSheet.在我的iPhone上它可以工作,但它不在iPad模拟器上.

这是我的代码:

@IBAction func dialog(sender: AnyObject) {

    let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .ActionSheet)
    let deleteAction = UIAlertAction(title: "Delete", style: .Default, handler: {

        (alert: UIAlertAction!) -> Void in
        println("Filtre Deleted")
    })

    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
        (alert: UIAlertAction!) -> Void in
        println("Cancelled")
    })

    optionMenu.addAction(deleteAction)
    optionMenu.addAction(cancelAction)

    self.presentViewController(optionMenu, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

而我的错误:

由于未捕获的异常'NSGenericException'而终止应用程序,原因是:'您的应用程序已呈现样式UIAlertControllerStyleActionSheet的UIAlertController().具有此样式的UIAlertController的modalPresentationStyle是UIModalPresentationPopover.您必须通过警报控制器的popoverPresentationController为此弹出窗口提供位置信息.您必须提供sourceView和sourceRect或barButtonItem.如果在显示警报控制器时不知道此信息,您可以在UIPopoverPresentationControllerDelegate方法-prepareForPopoverPresentation中提供它.

uiactionsheet ipad ios swift

78
推荐指数
5
解决办法
2万
查看次数

删除/停止dispatch_async iOS

我创建了一个dispatch_async来将数据下载到Web服务.

我使用possibilida中的按钮创建了一个警报,以取消/阻止下载.

我的问题是:

如何删除/停止dispatch_async?

这是我的发送:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
    doStuff();
}
Run Code Online (Sandbox Code Playgroud)

objective-c grand-central-dispatch ios swift

2
推荐指数
1
解决办法
2398
查看次数