从customcell转到viewController [英] Going to viewController from customcell

查看:113
本文介绍了从customcell转到viewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个加载自定义单元格的表格视图.自定义单元格上有一个按钮,单击此按钮将打开一个pickerview,其中有多个选项可供选择.

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.

问题是modalViewController方法无法正常工作,它给出了以下错误.

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   

v如何从自定义单元格调用其他视图?

How can v call other view from custom cell?

谢谢

推荐答案

首先,将您的类命名为选择器"是一个令人困惑的主意.您应该使用更具描述性的内容,而不是obj-c关键字.

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

在这里,委托ivar将指向您的视图控制器.要进行设置,请找到分配单元的位置,然后执行

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;

这篇关于从customcell转到viewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆