为什么用户定义的单元格的 UITextField 和单元格视图之间有这么多控制器

发布于 2024-10-03 06:20:07 字数 266 浏览 0 评论 0原文

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

UITextField-> UIView-> UITableViewCellContentView ->; MyCellView

还有两个更意想不到的视图。这些是什么以及为什么?

添加描述。)我已经制作了自己的单元格,并且有一个 UITextField。

I'd like to get parent view of UITextField on my user defined cell.
What I've tried is just call superview method and it returns UIView, not a my cell view.
So I invoked superview several times.

UITextField -> UIView -> UITableViewCellContentView -> MyCellView

There're two more unexpected view. What are those and WHY?

add desc.) I've made my own cell and there's an UITextField.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉风有信 2024-10-10 06:20:07

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

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

// now you get the view as MyCellView

A UITableViewCell have a contentView where the custom view s are added.
you can run a loop until you get the MyCellView

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

// now you get the view as MyCellView
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文