The UIImageView created in the interface builder is set to zero when necessary

I have an application in which a small number of objects are defined in MainWindow. A couple of these objects are the UIViewController and UIImageView, which come with this controller. When the application starts, the whole MainWindow.xib loads, and I see that this UIImageView is loaded into memory. At the moment, I do not need this UIImageView.

When I need a UIViewController, I do the usual alloc / init setup. At this point, when I look at this controller with a debugger, the controller is configured correctly, but the UIImageView, which was supposed to be pre-connected using Interface Builder, is always zero.

Any questions on how to ensure that this UIImageView is loaded into memory correctly? This is the only time I have a problem with the objects defined in this single MainWindow.xib file.

+1
source share
2 answers

Assuming you have connected the output view, all you have to do is access the property view. When you look in the debugger, you see the property corresponding to ivar. When you access a property in code, it should load for you. So it should be as simple as:

  [controller view];
+1
source

Not quite sure that I understand the problem, but instead of having a UIImageView in MainWindow.xib, why not have it in xxxViewController.xib, where you really need it?

0

Source: https://habr.com/ru/post/1785610/


All Articles