Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的用户定义的单元格上获得 UITextField 的父视图。我尝试过的只是调用 superview 方法,它返回 UIView,而不是我的单元格视图。所以我多次调用superview。
UITextField -> UIView -> UITableViewCellContentView -> MyCellView
还有两个意想不到的景象。那些是什么,为什么?
添加描述。)我已经制作了自己的单元格,并且有一个 UITextField。
UITableViewCell 有一个 contentView ,其中添加了自定义视图。你可以运行一个循环,直到你得到 MyCellView
View view = textView.superView; while( ![view isKindOfClass: [MyCellView class]]){ view = view.superView; } // now you get the view as MyCellView