将视图添加到操作表中

时间:2011-03-22 10:38:24

标签: iphone uiactionsheet

我可以将自定义UIViewController添加到ActionSheet中吗?

感谢

3 个答案:

答案 0 :(得分:10)

最后我发现它...我已经在UIActionSheet中添加了一个视图,它是UIViewController的子类。我在单独的文件中创建了一个视图(使用xib)。

UIActionSheet *asheet = [[UIActionSheet alloc] init];
[asheet showInView:self.view]; 
[asheet setFrame:CGRectMake(0, 230, 320, 230)];


CustomView *innerView = [[CustomView alloc] initWithNibName:@"CustomView" bundle:nil];
innerView.view.frame = CGRectMake(0, 10, 320, 210);
[asheet addSubview:innerView.view];
//[asheet addSubview:innerView];

[innerView release];
[asheet release];

答案 1 :(得分:1)

我最近创建了一个应用程序,其中我创建了操作表并在其中添加了一个选择器视图 首先,您需要在.h文件中为操作表创建对象及其属性,如下所示:

UIActionSheet *menuProperty;    

@property(nonatomic,retain) UIActionSheet *menuArea;  

然后您需要在.m文件中进行以下更改

menuArea = [[UIActionSheet alloc] initWithTitle:nil  delegate:self
                                            cancelButtonTitle:@"Done"  
                                        destructiveButtonTitle:nil
                                             otherButtonTitles:nil];  


// Add the picker  
pickerArea = [[UIPickerView alloc] initWithFrame:CGRectMake(0,185,0,0)];  

pickerArea.delegate = self;  
pickerArea.showsSelectionIndicator = YES;    // note this is default to NO  

[menuArea addSubview:pickerArea];  
[menuArea showInView:self.view];  
[menuArea setBounds:CGRectMake(0,0,320, 600)];  

答案 2 :(得分:-1)

我认为这些链接会对你有所帮助。我从未在uiactionsheet中添加视图,但经过一些搜索后我认为我们可以添加。

http://www.ifans.com/forums/showthread.php?t=301851

how add the action sheet in the cell of table view