半透明modalViewController
我一直在研究这个,似乎唯一的方法是使用 UIActionSheet,问题是我的 UIActionSheet 仅覆盖屏幕的一半,我的代码是:
MyViewController *myVC = [[myViewController alloc] init];
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"\n\n"
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:@"done"
otherButtonTitles:nil];
[myActionSheet addSubview:myVC.view];
[myActionSheet showInView:currentView];
[myActionSheet release];
另外,我如何从 MyViewController 中消除此 UIActionSheet?还有比这更好的解决方案吗?这是我所说的加载一半屏幕的屏幕截图:
这里是 示例项目来说明我的问题。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIActionSheet
将根据其中UIButton
的数量增加或减少其高度。您可以做的是在您的视图上方添加另一个具有所需 alpha 的视图。并根据您的要求将其从子视图中删除并添加到子视图中,即在显示操作表时添加子视图,并在关闭UIActionSheet
时将其删除。我希望这与您的问题相关,并能帮助您解决问题。UIActionSheet
will increase or decrease it's height according to the number ofUIButton
s in it. What you can do is add another view above your view with your desired alpha. And remove it from subview and add in subview according to your requirement i.e. add subview when you are displaying actionsheet and remove when you are dismissingUIActionSheet
. I hope this is relevant to your question and it will help you to solve your problem.问题是由于 TestViewController 的框架大小以及将 UIView 添加为
UIActionSheet
的子视图的方法造成的。进行以下更改,即可正确关闭!
在该方法中实现 willPresentActionSheet 和 addSubView
并在 TestViewController 的 viewDidLoad 中设置
The problem is because of the frame size of your TestViewController and method for adding the UIView as a subView of the
UIActionSheet
.Make the following changes, and it is dismissing properly !
Implement
willPresentActionSheet
andaddSubView
in that methodAnd in the
viewDidLoad
of theTestViewController
, set