我一直在研究这个问题,似乎唯一的方法是使用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?还有比这更好的解决方案吗?这是我所说的加载半个屏幕的截图:
下面是a sample project来说明我的问题。
发布于 2011-08-06 15:03:20
UIActionSheet会根据其中的UIButton数增加或减少其高度。你能做的就是用你想要的alpha在你的视图上添加另一个视图。并将其从子视图中删除,并根据您的需求添加到子视图中,即在显示actionsheet时添加子视图,在关闭UIActionSheet时删除。我希望这与你的问题相关,它将帮助你解决你的问题。
发布于 2011-08-06 14:55:59
这个问题是由于您的TestViewController的帧大小和将UIView添加为UIActionSheet的subView的方法造成的。
进行以下更改,它将被正确地清除!
在该方法中实现willPresentActionSheet和addSubView
- (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];
}在TestViewController的viewDidLoad中,设置
- (void)viewDidLoad
{
self.view.frame = CGRectMake(0,0 , 320, 60);
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}https://stackoverflow.com/questions/6965015
复制相似问题