That's weird. I wrote and tested the script on my iPad. Did you run the exact script in the linked post? Should be the second script that doesn't crash.
Here is the code, if you don't care to guess.
B.
# coding: utf-8
from objc_util import *
import ctypes
import ui
SUIViewController = ObjCClass('SUIViewController')
UIAlertController = ObjCClass('UIAlertController')
UIAlertAction = ObjCClass('UIAlertAction')
def ok_pressed(sender):
print 'OK pressed', ObjCInstance(sender), dir(ObjCInstance(sender))
alert = UIAlertController.alertControllerWithTitle_message_preferredStyle_(ns('My Alert'), ns('My Message'), 0)
alert_action_block = ObjCBlock(ok_pressed, None, [c_void_p])
default_action = UIAlertAction.actionWithTitle_style_handler_(ns('OK'), 0, alert_action_block)
alert.addAction_(default_action)
##rvc.presentModalViewController_animated_(alert, True)
## Stop Crashes
retain_global(alert_action_block)
def button_tapped(sender):
super_view = sender.superview
super_view_pntr = ObjCInstance(super_view)
vc = SUIViewController.viewControllerForView_(super_view_pntr)
vc.presentModalViewController_animated_(alert, True)
view = ui.View(frame=(0,0,500,500))
view.name = 'Demo'
view.background_color = 'white'
button = ui.Button(title='Tap me!')
button.center = (view.width * 0.5, view.height * 0.5)
button.flex = 'LRTB'
button.action = button_tapped
view.add_subview(button)
view.present('sheet')