Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从自定义UITableViewCell访问uitextFields文本_Ios_Objective C_Uitableview_Custom Cell - Fatal编程技术网

Ios 从自定义UITableViewCell访问uitextFields文本

Ios 从自定义UITableViewCell访问uitextFields文本,ios,objective-c,uitableview,custom-cell,Ios,Objective C,Uitableview,Custom Cell,我正在尝试从自定义单元格中的UItextField获取文本。我试着创建一个协议 @class customCellClass @protocol CustomCellDelegate -(void)passText:(CustomCell *)customCell withText:(NSString *)text; @end ... @interface @property (nonatomic, weak) id<CustomCellDelegate> delegate;

我正在尝试从自定义单元格中的
UItextField
获取文本。我试着创建一个协议

@class customCellClass
@protocol CustomCellDelegate 

-(void)passText:(CustomCell *)customCell withText:(NSString *)text;
@end

...
@interface
@property (nonatomic, weak) id<CustomCellDelegate> delegate;
@end


@interface MainCV<CustomCellDelegate>
@end

@implementation MainVC 
@end

- (void)viewDidLoad {
CustomCell *cell = ... allocation and initialization
cell.delegate = self;
}

-(void)passText:(CustomCell *)customCell withText:(NSString *)text
{

}

- (void)viewDidLoad {
CustomCell *cell = [[customCellClass alloc] init];
cell.delegate = self;
}
但它不允许我做最后一件事:
[self.delegate passText…

有人能解释一下为什么它不起作用,并帮我找出一个有效的方法来获取文本字段文本

CustomCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];

然后你可以从单元格中访问
textField.text

很简单,只要在textField发生变化时做你想做的事情。我有多个textField。我如何区分1和其他文本字段?你应该能够从
customCell
中获取indexath。你的意思是:
customCellClass*cell=(customCellClass*)textField.superview.superview.superview;
我没有使用
didSelectRow…
did
textField
嵌入到单元格中吗?是的,`textField是链接的,为什么不使用
cell.myTextField
来访问值?我如何获取
cell
?(我需要它在
cellForRow…
CustomCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];