2

I am working on a Pythonista script that displays a UITabBarController, which contains multiple UINavigationControllers, containing UITableViewControllers. At some point I need to display a UIAlertController, but all the methods I've tried to present it either crash the app or push the UIAlertController to the navigation stack.

My code:

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

Thanks in advance, any help is greatly appreciated.

Benjy Wiener
  • 1,085
  • 2
  • 9
  • 27
  • Hey, check out the official Pythonista forums. There's a great community of people helping with pythonista-specific questions. A few users in particular are good with objc_util. The forum is here: https://forum.omz-software.com/category/5/pythonista – Luke Taylor Jan 29 '16 at 01:16
  • @LukeTaylor I've tried looking there, but I'll go post the question there, hopefully I'all get an answer somewhere. Thanks – Benjy Wiener Jan 29 '16 at 01:32
  • Try mentioning a user called @JonB in your post. He's pretty knowledgeable about this stuff. Anyway, I almost always get some kind of response from there anywhere from 10 minutes to 3 hours after posting, and people are really willing to help. – Luke Taylor Jan 29 '16 at 01:33
  • @LukeTaylor Thanks, will do! – Benjy Wiener Jan 29 '16 at 01:34

1 Answers1

0

Turns out the problem was I was trying to present an Action Sheet on an iPad without setting up the popoverPresentationController.

Benjy Wiener
  • 1,085
  • 2
  • 9
  • 27