【问题标题】:Pythonista: How can I present a UIAlertController?Pythonista:如何呈现 UIAlertController?
【发布时间】:2016-05-06 14:53:03
【问题描述】:

我正在编写一个 Pythonista 脚本,该脚本显示一个 UITabBarController,其中包含多个 UINavigationControllers,其中包含 UITableViewControllers。在某些时候我需要显示一个UIAlertController,但我尝试展示它的所有方法要么使应用程序崩溃,要么将UIAlertController 推送到导航堆栈。

我的代码:

from objc_util import *
from UIKit import *

alert = UIAlertController.alertControllerWithTitle_message_preferredStyle_('Title', 'Message', 0)
def alertActionCancel(sender):
  print 'Cancelled!'
alertActionCancelBlock = ObjCBlock(alertActionCancel, None, [c_void_p])
retain_global(alertActionCancelBlock)
alert.addAction_(UIAlertAction.actionWithTitle_style_handler_('Cancel', 1, alertActionCancelBlock))
myTableViewController.presentViewController_animated_completion_(alert, True, None) # This line crashes Pythonista

在此先感谢,非常感谢任何帮助。

【问题讨论】:

  • 嘿,看看官方 Pythonista 论坛。有一个很棒的社区可以帮助解决 pythonista 特定的问题。一些用户尤其擅长使用 objc_util。论坛在这里:forum.omz-software.com/category/5/pythonista
  • @LukeTaylor 我试过看那里,但我会在那里发布问题,希望我能在某个地方得到答案。谢谢
  • 尝试在您的帖子中提及名为@JonB 的用户。他对这些东西非常了解。无论如何,我几乎总是在发布后 10 分钟到 3 小时内从那里得到某种回应,人们真的很愿意提供帮助。
  • @LukeTaylor 谢谢,会的!

标签: python ios objective-c uialertcontroller pythonista


【解决方案1】:

原来的问题是我试图在 iPad 上展示一个操作表而不设置 popoverPresentationController

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-22
    • 2015-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-13
    • 1970-01-01
    相关资源
    最近更新 更多