我如何检查每个出口实际上都指向某个视图?

发布于 2024-10-22 10:05:19 字数 276 浏览 1 评论 0原文

我如何检查每个出口实际上都指向某个视图? 如何在 Interface Builder 中手动设置对象的索引? 我们在上一个主题中讨论了 当我正在获取子视图的索引

我检查了我的插座 在此处输入图像描述

How can I check that every outlet actually points to some view ?
How can I manually set the index of the object in Interface Builder ?
we discussed in previous topic There is a problem when i am getting index of subview

i checked my outlet
enter image description here

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

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

发布评论

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

评论(1

可爱咩 2024-10-29 10:05:19

如果为零,则表示未正确附加。即

if (nil == distanceTextField)
  NSLog(@"distanceTextField not attached.");

,但是,仅仅因为连接了插座并不意味着它绝对是任何东西的子视图:)

如果您收到内存不足警告,那么您的控制器将释放其所有视图。这会将它们从 ui 中删除,但不会从插座中删除它们,除非您告诉它:)

完全有可能出现 distanceTextField 不为 nil 但 distanceTextField.superview 为 nil 的情况。

另外,仅仅因为您创建了一个控制器并不意味着它已经创建了所有视图 - 它会等到最后一刻才创建它们以节省内存/加速加载等。

在 viewDidLoad 之前,您的出口将为零已在您的控制器内部调用。

If it's nil it's not correctly attached. i.e.

if (nil == distanceTextField)
  NSLog(@"distanceTextField not attached.");

However, just because an outlet is attached doesn't mean that it's definitely a subview of anything :)

If you get a low memory warning then your controller will release all of it's views. This will remove them from the ui but won't remove them from the outlet unless you tell it to :)

It's perfectly possible to get the situation where distanceTextField is not nil but distanceTextField.superview is nil.

Also, just because you have created a controller doesn't mean that it's created all of it's views yet - it will wait until the last minute to create them to save memory / speed up loading etc.

You will get nil for your outlets until viewDidLoad has been called inside your controller.

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