关于 IBOutlets 的令人困惑的错误
我对此已经伤透脑筋很久了,但我就是无法弄清楚。
在我的视图控制器的视图 Did Load 方法中,如果我尝试对 IBOutlet 连接的 imageView 进行一些更改,它是无响应的。它根本不响应我对 IBOutlet 元素所做的任何更改。例如:如果我在 IB 中有一个 imageView 并通过 IBOutlet 连接,并且我尝试设置此 ImageView 的隐藏属性,它不会响应。为什么会这样,我实在无法理解。
然后,我将该 imageView 添加到另一个视图,并将该组合作为子视图添加到该视图。然后我可以更改此 imageView 元素。但是,如果我尝试使用 viewDidLoad 以外的其他方法访问此 imageView,应用程序就会崩溃。 imageView 是一个实例变量。
Iv been breaking my head on this for long but im just not able to figure it out.
In the view Did Load method of my view controller if i try to make some changes to an imageView connected by an IBOutlet, it is non-responsive. It simply does not respond to any changes im making to IBOutlet elements. For eg: if i have an imageView in IB and its connected thru an IBOutlet and i try to set the hidden property of this ImageView it does not respond. Why this is so is beyond me.
I then added that imageView to another view and added the combination as a subView to this view. Then I could make changes to this imageView elements. But if i try to access this imageView in another method other than viewDidLoad, the application crashes. The imageView is an instance variable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最可能的解释是 imageView 在 IB 中根本没有连接。由于应用程序在访问时崩溃,因此 IBOutlet 可能连接到另一个对象,而不仅仅是空的。
The most likely explanaintion is the the imageView is simply not connected in IB. Since the app crashes upon access, the IBOutlet is probably connected to another object instead of just being empty.