iphone - 从 customcell 转到 viewController

标签 iphone ios custom-cell uipickerviewcontroller

我有一个表格 View ,其中加载了自定义单元格。自定义单元格有一个按钮,单击该按钮将打开一个 pickerview,其中有可供选择的选项。

问题是 modalViewController 方法不起作用,它给出了以下错误。

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 如何从自定义单元格调用其他 View ?

谢谢

最佳答案

首先,将您的类命名为“Selector”是一个非常令人困惑的想法。您应该使用更具描述性的内容,以及还不是 obj-c 关键字的内容。

至于您的问题,我认为您应该使用委托(delegate)来获取从单元格 View 到 Controller 的引用。在您的自定义单元格 View 类中,执行如下操作:

@property (nonatomic, assign) id delegate;

// implementation
@synthesize delegate = _delegate;

// in your cell... method
[self.delegate presentPicker];

在这里,委托(delegate) ivar 将指向您的 View Controller 。要进行设置,请找到您分配单元格的位置,然后执行

ACell *aCell = [ACell alloc] init];
aCell.delegate = self;

关于iphone - 从 customcell 转到 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7802693/

相关文章:

ios - 如何使用 Swift 在 CustomCell 中将 inputAccessoryView 实现到 UITextField?

iphone - 奇怪的 NSDate 和 NSDateFormatter 行为

ios - iOS SDK 中的 MDM iPCU 配置文件安装失败

ios - 显示复选标记附件 View 移动表格内容

c# - 向 datagridView 中的某些单元格添加按钮

ios - 核心数据推导表达式键路径使用运算符作为中间组件

ios - 通过传入数组而不是 varlist 创建 UIActionSheet 'otherButtons'

iphone - 如何使用 GET 方法 JSON Objective C 在 NSRequestURL 中传递特殊字符(如 #、@、%、$)

iphone - 如何确定 Mac OS X 上静态库 (.a) 的目标体系结构?

ios - 如何让 Chrome Cast 在 iOS 后台运行?