adding view into action sheet

2019-02-14 14:47发布

问题:

Can I add my custom UIViewController into the ActionSheet ?

thanks

回答1:

finally I've find it... I've added a view which is subclass of UIViewController into the UIActionSheet. I've created a view in separate file (using 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];


回答2:

I recently created an application where I created action sheet and added a picker view in it.
Firstly you need to create object for action sheet in your .h file as along with its properties as follows :

UIActionSheet *menuProperty;    

@property(nonatomic,retain) UIActionSheet *menuArea;  

Then you need to make following changes in your .m file

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)];  


回答3:

i think these links will help u. i have never add a view in uiactionsheet but after a little search i think we can add.

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

how add the action sheet in the cell of table view