Ale*_*lec 5 uiactionsheet ios ios7
我正在创建一个标准UIActionSheet,我不需要破坏性按钮和底部的取消按钮.我的其他按钮标题存储在一个NSArray.
但是,我对行分隔符的行为非常奇怪,特别是当我尝试添加标题时.
我在这里完全失败了.救命?
实施#1(无标题)
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
for (NSString *title in self.myArray) {
[actionSheet addButtonWithTitle:title];
}
actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet showFromToolbar:(UIToolbar*)self.toolbarView];
Run Code Online (Sandbox Code Playgroud)
实施#2(带标题)
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
for (NSString *title in self.myArray) {
[actionSheet addButtonWithTitle:title];
}
actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet showFromToolbar:(UIToolbar*)self.toolbarView];
Run Code Online (Sandbox Code Playgroud)
结果#1(无标题)
当我有10个或更少的按钮,不包括取消按钮时,所有按钮都适合屏幕.行分隔符扩展了操作表的整个宽度.这是预期的行为.
当我有11个或更多按钮时,操作表实现滚动.分隔符现在一直向左延伸,但在右边留出空间(~25px?).此外,当我向上和向下滚动时,每次在最后一个非取消按钮之后添加/移除额外的分隔符(扩展全宽).
结果#2(标题)
当我有10个或更少的按钮,不包括取消按钮时,所有按钮都适合屏幕.行分隔符扩展了操作表的整个宽度.还有一个分隔符,在顶部标题和第一个按钮之间延伸全宽.这是预期的行为.
当我有11个或更多按钮时,操作表实现滚动.分隔符现在一直向左延伸,但在右边留出空间(~25px?).标题和按钮之间的分隔符在分隔符的两侧留出空间(~5px).现在当我向上和向下滚动时,我得到了非常奇怪的分隔符行为,分隔符在奇怪的地方被添加和删除.
如果我快速向上和向下滚动,我实际上可以在列表中的第一个和第二个按钮之间获得另一个额外的分隔符,黑色,延伸到全宽.
试图解决方案
我想也许我不应该使用内置的init函数,因为我没有真正使用任何参数.没有标题的行为没有区别.
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
for (NSString *title in self.myArray) {
[actionSheet addButtonWithTitle:title];
}
actionSheet.title = @"Title";
actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet showFromToolbar:(UIToolbar*)self.toolbarView];
Run Code Online (Sandbox Code Playgroud)
尝试解决方案#2(根据Leo Natan)
UIActionSheet *actionSheet =[[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destroy" otherButtonTitles:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",nil];
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
Run Code Online (Sandbox Code Playgroud)
仍然没有变化.如果"UIActionSheet"上有足够的项目使其滚动,则分隔符行为将变得不稳定.
| 归档时间: |
|
| 查看次数: |
878 次 |
| 最近记录: |