【发布时间】:2013-11-08 19:21:18
【问题描述】:
我有一个UIActionSheet,我有条件地向其中添加按钮。如果有很多按钮(对于纵向视图更是如此),破坏性按钮会从操作表中分离(如预期的那样)以允许项目滚动。不正确的事情是它没有背景。
UIActionSheet *sheet = [[UIActionSheet alloc]initWithTitle:nil
delegate:self
cancelButtonTitle: nil
destructiveButtonTitle:@"Changed my mind"
otherButtonTitles:MAILBUTTON, BOOKMARKSBUTTON, CLEARCOOKIESBUTTON, nil];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[sheet addButtonWithTitle:CAMERABUTTON];
}
sheet.tag = ACTION_SHEET;
if ([UIPrintInteractionController isPrintingAvailable])
{
[sheet addButtonWithTitle:PRINTBUTTON];
}
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if ([prefs boolForKey:BUMP_ENABLED_KEY] == YES)
{
[sheet addButtonWithTitle:BUMPRECEIVEBUTTON];
if ([prefs boolForKey:BUMP_ALLOW_SENDING_KEY] == YES)
[sheet addButtonWithTitle:BUMPSENDBUTTON];
}
[sheet addButtonWithTitle: @""];
[sheet setCancelButtonIndex: sheet.numberOfButtons - 1];
[sheet showInView:self.view];
在纵向模式下看起来不错,破坏性按钮有背景。如果我添加更多按钮,它具有与上面相同的行为。
【问题讨论】:
-
有同样的问题。你有没有找到一个不那么 hacky 的解决方案?谢谢。
-
@anas 不,我坚持使用这个解决方案。我们已经在多种设备和不同的操作系统版本上进行了多次测试,但没有遇到问题。下一个最好的事情是苹果解决这个错误,IMO
标签: ios cocoa-touch ios7 uiactionsheet