Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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
Iphone 为什么在用户定义的单元格和#x27;s UITextField和单元格视图_Iphone_Superview - Fatal编程技术网

Iphone 为什么在用户定义的单元格和#x27;s UITextField和单元格视图

Iphone 为什么在用户定义的单元格和#x27;s UITextField和单元格视图,iphone,superview,Iphone,Superview,我想在用户定义的单元格上获取UITextField的父视图。 我尝试的只是调用superview方法,它返回UIView,而不是MyCell视图。 所以我多次调用superview UITextField->UIView->UITableViewCellContentView->MyCellView View view = textView.superView; while( ![view isKindOfClass: [MyCellView class]]){ view = view.su

我想在用户定义的单元格上获取UITextField的父视图。 我尝试的只是调用superview方法,它返回UIView,而不是MyCell视图。 所以我多次调用superview

UITextField->UIView->UITableViewCellContentView->MyCellView

View view = textView.superView;
while( ![view isKindOfClass: [MyCellView class]]){
  view = view.superView;
}

// now you get the view as MyCellView
还有两个意想不到的景象。这些是什么?为什么


添加说明。)我创建了自己的单元格,其中有一个UITextField。

UITableViewCell有一个添加自定义视图的contentView。 您可以运行循环,直到获得MyCellView

View view = textView.superView;
while( ![view isKindOfClass: [MyCellView class]]){
  view = view.superView;
}

// now you get the view as MyCellView

UITableViewCellContentView中的UIView由应用程序创建(可能由界面生成器创建)。内容视图对应于UITableViewCell.contentView属性;当您的单元格具有辅助视图或编辑控件时,它可以帮助您进行正确的布局。