Created
July 23, 2012 16:57
-
-
Save beatinaniwa/3164705 to your computer and use it in GitHub Desktop.
ActionSheet Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppDelegate | |
| def application(application, didFinishLaunchingWithOptions:launchOptions) | |
| @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
| @viewController = UIViewController.alloc.init | |
| @viewController.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemAction, target:self, action:'tapped:') | |
| @window.rootViewController = UINavigationController.alloc.initWithRootViewController(@viewController) | |
| @window.rootViewController.wantsFullScreenLayout = true | |
| @window.makeKeyAndVisible | |
| true | |
| end | |
| def tapped(sender) | |
| # Failed | |
| actionSheet = UIActionSheet.alloc.initWithTitle("Test", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:nil, otherButtonTitles:"WRYYY", "View Info") | |
| actionSheet.showInView(@viewController.view) | |
| # Passed | |
| # @actionSheet ||= UIActionSheet.alloc.initWithTitle("Test", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:nil, otherButtonTitles:"WRYYY", "View Info") | |
| # @actionSheet.showInView(@viewController.view) | |
| end | |
| end |
あ、デバッグ分付け足しながら動かしたので行数、ずれてるかもです。
よくわかりませんが、謎動作であることだけは確信が持てました。
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@viewController = UIViewController.alloc.init
@viewController.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemAction, target:self, action:'tapped:')
@viewController.view.backgroundColor = UIColor.whiteColor
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(@viewController)
@window.rootViewController.wantsFullScreenLayout = true
@window.makeKeyAndVisible
true
end
def tapped(sender)
actionSheet = UIActionSheet.alloc.initWithTitle("Test", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:nil, otherButtonTitles:"WRYYY", "View Info")
p actionSheet # ここをコメントアウトすると落ちる
end
end
Author
サポートチケットを投げたところLaurentから返事をもらいました。許可をもらったのでそのまま転載します。これで解決しました。
The crash sometimes happens because the otherButtonTitles argument is supposed to be a nil-terminated list. If nil is not passed, the method will keep scanning the arguments on the stack.
Changing this line
actionSheet = UIActionSheet.alloc.initWithTitle("Test", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:nil, otherButtonTitles:"WRYYY", "View Info")
to
actionSheet = UIActionSheet.alloc.initWithTitle("Test", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:nil, otherButtonTitles:"WRYYY", "View Info", nil)
might fix the problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
以下の例外で落ちますね。