设置 UIActionSheet 的界限?
我有一个 UIActionSheet,想要调整(增加)其宽度以容纳它包含的按钮的文本。这些按钮的宽度是在运行时确定的,并且可以在运行时改变。
我已经用 [[actionSheet superview] superview] 来获取包含的 UIPopoverView,但是更改其框架并没有产生所需的结果。而且,大多数情况下,这似乎是一种极其脆弱的方式。
我尝试了 [actionSheet sizeToFit] 没有任何明显的效果。
所以,我希望我忽略了一些调整 UIActionSheet/UIPopoverView 大小的明显方法。
谢谢。
I have a UIActionSheet and would like to adjust (increase) its width to accommodate the text of the buttons that it contains. The width of these buttons is determined at runtime and could change during runtime.
I have mucked around with [[actionSheet superview] superview] to get the containing UIPopoverView, but changing its frame doesn't yield desired results. And, mostly, this just seems an extremely fragile way to go.
I tried [actionSheet sizeToFit] without any noticeable effect.
So, I am hoping that I have overlooked some obvious method for adjusting the size of the UIActionSheet/UIPopoverView.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您可能已经发现的那样,它不起作用。常见的解决方案是创建一个自定义的 UIViewController 并使用 UIViewController 的 PresentModalViewController 来显示它,这可以为您提供一个很好的向上滑动过渡,就像 UIActionSheet 的显示方式一样。
但该解决方案缺少一些东西。 UIActionSheet 向上滑动,但不是一直滑动,在父视图上留下半透明的覆盖物。有一个包含代码和项目的精彩详细教程,它将尝试向您展示如何显示具有相同效果的自定义视图。
http://www.nearinfinity.com/blogs/andrew_homeyer/display_a_custom_uiview_like_a.html
我希望我能在这个人制作之前制作这个教程!他在我之前到达那里
PK
It doesn't work, as you have probably figured out. The common solution is to create a custom UIViewController and display it using UIViewController's presentModalViewController, which can give you a nice slide up transition, much like how a UIActionSheet appears.
But that solution is missing something. A UIActionSheet slides up, but not all the way, leaving a semi-transparent covering over the parent view. There is a brilliant detailed tutorial with code and project which will try to show you how to display a custom view with this same effect.
http://www.nearinfinity.com/blogs/andrew_homeyer/display_a_custom_uiview_like_a.html
I wish i made this tutorial before this guy made it! he got there before me
PK
这很容易做到。
That can be done easily.