【发布时间】:2013-12-29 18:00:43
【问题描述】:
这是我在stackoverflow上的第一篇文章,如果我犯了一些错误,请原谅我。
我是一个相对较新的应用设计师,我一直在开发一个新应用,希望能尽快发布。我最近遇到了一个问题。我无法使用UIActionSheet。虽然它显示正常,但按钮只是使操作表消失。我尝试了很多东西都无济于事;我做了this thread 中建议的所有事情(由有类似但不相同问题的人提出)。我已经测试并确保没有使用NSLog 完全调用该函数。我尝试过更改showInView,尽管这似乎不会有所作为。所以无论如何,这是我当前的代码:
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"You Shook?" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"End Game" otherButtonTitles:@"Settings", nil];
[actionSheet showInView:self.view];
}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
UIAlertView *endGameAlertView = [[UIAlertView alloc] initWithTitle:@"End Game" message:@"Are you sure you want to end the current game?" delegate:nil cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[endGameAlertView show];
}
else
{
UIAlertView *unimplementedSettingsAlertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"This feature is not yet implemented" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
[unimplementedSettingsAlertView show];
}
}
如您所见,actionSheet 是通过摇动设备触发的(效果很好),唯一的问题是按钮除了关闭 actionSheet 之外什么都不做。我在 OSX 10.9.1 上使用 Xcode 5.0.2。如果我遗漏了任何重要信息,请告诉我。提前谢谢!
~初级
【问题讨论】:
标签: ios objective-c cocoa-touch uiactionsheet uiactionsheetdelegate