Going to viewController from customcell

你。 提交于 2019-12-12 01:53:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!