iPhone-调整UIActionSheet的大小 [英] iPhone - adjusting the size of a UIActionSheet

查看:64
本文介绍了iPhone-调整UIActionSheet的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要呈现一个UIActionSheet,其中将显示10个按钮.当我在iPad上执行此操作时,UIActionSheet会在垂直方向上很长的弹出式窗口中显示(从外观上看不是很漂亮).是否可以将UIActionSheet的大小指定为最大大小?

I need to present a UIActionSheet that will show 10 buttons. When I do that on iPad, the UIActionSheet shows on a popover that is very long vertically (not aesthetically pretty). Is that possible to specify the UIActionSheet size to a maximum size?

我已经尝试过了

myActionSheet.frame = CGRectMake(0,0,300,300);
myActionSheet.bounds = CGRectMake(0,0,300,300);

并且还尝试将这些行放进去

and have also tried to put these lines inside

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {

没有成功.

任何线索?

谢谢

推荐答案

我认为这是您无法真正使用诸如UIActionSheet之类的内置类来实现目标的情况之一.我认为它不适用于您具有多达10个按钮的情况.正如您所发现的那样,它的伸缩性不是很好.

I think this is one of the cases where you can't really use a built-in class like the UIActionSheet to accomplish your goal. I don't think it is designed to be used for cases where you have as many buttons as 10. It just doesn't scale very well, just as you have discovered.

但让我们假装可以更改大小.更改大小会怎样?每个按钮都有一个最小尺寸,以便可以点击.而且您还需要在按钮之间留出一些空间,以免造成误操作.因此,即使您可以更改大小,也不会减少太多.而且,由于它并非旨在更改大小,因此您必须尝试访问所有按钮,并调整大小和移动它们.有人可能会争辩说,可以将按钮放置在列中,但是由于未实现该按钮,因此如果将UIActionSheet设置得更宽,仍将无济于事.

But let's pretend that it would be possible to change the size. What should happen when you change the size? There is a minimum size for each button for it to be tapable. And you also need some space between the buttons as to not cause a misstap. So even if you could change the size it couldn't be reduced by very much. And since it's not intended to be able to change the size you would have to try and access all the buttons and resize and move them as well. One could argue that perhaps the buttons could be placed in columns but since that is not implemented it would still not help if you made the UIActionSheet any wider.

我建议您之一:

  1. 使用您喜欢的所有10个按钮来创建自己的自定义视图.
  2. 使用表格视图显示选项.由于可以滚动表格视图,因此您可以获取所需的大小.

如果您在弹出窗口中显示的UIViewController上将modalInPopover设置为YES,则用户必须做出选择才能继续.

If you set modalInPopover to YES on the UIViewController you present in the popover the user must make a choice before she can move on.

这篇关于iPhone-调整UIActionSheet的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆