UIPopoverController 中 UIActionsheet 的大小问题
我已将带有动态数量按钮的 UIActionsheet 添加到 UIPopovercontroller,如果显示弹出窗口,则会出现该控制器。我的问题是,如果按钮数量太多,UIActionsheet 超出了弹出框的边框,并且按钮不会显示为列表。在横向视图中,操作表将按钮显示为列表,但操作表的大小再次大于弹出窗口,因此弹出窗口顶部的文本不可见。
我通过以下方式添加了 UIActionsheet:
BookingDataDefaults *defaults = [BookingDataDefaults getInstance];
if([defaults.profils count]>0){
UIActionSheet *actionSheet = [[UIActionSheet alloc]init];
actionSheet.delegate = self;
actionSheet.title = NSLocalizedString(@"title", nil);
int count = 0;
for (ReservationProfil *profil in defaults.profils) {
[actionSheet addButtonWithTitle:profil.profilName];
count++;
}
[actionSheet addButtonWithTitle:NSLocalizedString(@"standard", nil)];
count++;
[actionSheet addButtonWithTitle:NSLocalizedString(@"cancel", nil)];
actionSheet.destructiveButtonIndex = count;
[actionSheet showInView:self];
[actionSheet release];
}
操作表可以完美地与少量按钮配合使用。
有什么方法可以设置 UIActionsheet 的最大大小或更改我认为的某些内容以消除该问题。
PS:弹出窗口中视图的大小正是弹出窗口的 contentSize 的大小。
编辑:
我已经测试了 Nitish 的解决方案,它稍微好一点,但并不完美,因为子视图不会根据超级视图更改其大小。最好的解决方案是将操作表的大小设置为弹出窗口的大小。它将操作表放在弹出窗口的顶部,但列表太大或未显示。 结果如下所示:
肖像旧->新肖像
风景旧->新景观
I've added an UIActionsheet with a dynamically number of buttons to a UIPopovercontroller, that appears if the popover is shown. My problem is that if the number of buttons is to hight the UIActionsheet exceeds the borders of the popover and the buttons are not shown as a list. At landscape view the actionsheet shows the buttons as a list, but the size of the actionsheet is again bigger the the popover, so that the text at the top of the popover is not visisble.
I've added the UIActionsheet in the following way:
BookingDataDefaults *defaults = [BookingDataDefaults getInstance];
if([defaults.profils count]>0){
UIActionSheet *actionSheet = [[UIActionSheet alloc]init];
actionSheet.delegate = self;
actionSheet.title = NSLocalizedString(@"title", nil);
int count = 0;
for (ReservationProfil *profil in defaults.profils) {
[actionSheet addButtonWithTitle:profil.profilName];
count++;
}
[actionSheet addButtonWithTitle:NSLocalizedString(@"standard", nil)];
count++;
[actionSheet addButtonWithTitle:NSLocalizedString(@"cancel", nil)];
actionSheet.destructiveButtonIndex = count;
[actionSheet showInView:self];
[actionSheet release];
}
The actionsheet works with a small number of buttons perfectly.
Is there any way to set a maximum size of the UIActionsheet or change something at my view to get rid of that problem.
PS: The size of the view in the popover is exactly the size of the contentSize of the popover.
EDIT:
I've test Nitish's solution, it's a little bit better but not perfect, because the subviews do not changed their size according to the superview. The best solution was to set the size of the actionsheet to the size of the popover. it places the actionsheet at the top of the popover but the list is eather to big or not shown.
The result is shown down:
Portrait old -> Portrait new
Landscape old -> Landscape new
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论