首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >半透明modalViewController

半透明modalViewController
EN

Stack Overflow用户
提问于 2011-08-06 13:36:12
回答 2查看 155关注 0票数 1

我一直在研究这个问题,似乎唯一的方法是使用UIActionSheet,问题是我的UIActionSheet只覆盖了半个屏幕,我的代码是:

代码语言:javascript
复制
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?还有比这更好的解决方案吗?这是我所说的加载半个屏幕的截图:

screenshot

下面是a sample project来说明我的问题。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-06 15:03:20

UIActionSheet会根据其中的UIButton数增加或减少其高度。你能做的就是用你想要的alpha在你的视图上添加另一个视图。并将其从子视图中删除,并根据您的需求添加到子视图中,即在显示actionsheet时添加子视图,在关闭UIActionSheet时删除。我希望这与你的问题相关,它将帮助你解决你的问题。

票数 1
EN

Stack Overflow用户

发布于 2011-08-06 14:55:59

这个问题是由于您的TestViewController的帧大小和将UIView添加为UIActionSheet的subView的方法造成的。

进行以下更改,它将被正确地清除!

在该方法中实现willPresentActionSheetaddSubView

代码语言:javascript
复制
- (IBAction)pressed:(id)sender
{
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"\n\n" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"done" otherButtonTitles:nil];
[myActionSheet showInView:self.view];
[myActionSheet release];   
}


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

TestViewController *myVC = [[TestViewController alloc] init];
[actionSheet addSubview:myVC.view];

}

TestViewControllerviewDidLoad中,设置

代码语言:javascript
复制
- (void)viewDidLoad
{
self.view.frame = CGRectMake(0,0 , 320, 60);
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6965015

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档