问题
i am having a tableview in which custom cells are loaded.Custom cell has a button on click of which a pickerview will open which will have options to choose from.
The problem is that modalViewController method is not working, it is giving the following error.
Selector *sel = [[Selector alloc]initWithNibName:@"Selector" bundle:nil];
[self PresentModalViewController:sel animated:YES];
error:property presentModalViewController not found on object of type CustomCell *...and selector is the pickerview controller class...the method is written in ibaction function in customcell.m file
How can v call other view from custom cell?
thanks
回答1:
First, naming your class "Selector" is a horribly confusing idea. You should use something more descriptive, and something that is not already an obj-c keyword.
As for your problem, I think you should use a delegate to get a reference from your cell view to the controller. In your custom cell view class, do something like:
@property (nonatomic, assign) id delegate;
// implementation
@synthesize delegate = _delegate;
// in your cell... method
[self.delegate presentPicker];
Here, the delegate ivar would point back to your view controller. To set that up, find the place where you alloc your cell, and do
ACell *aCell = [ACell alloc] init];
aCell.delegate = self;
来源:https://stackoverflow.com/questions/7802693/going-to-viewcontroller-from-customcell