60868

UIImageView Created In Interface Builder Set To nil When Needed

Question:

I have an application where small number of objects are defined in the MainWindow. A pair of these objects are a UIViewController and the UIImageView that goes along with this controller. When the application starts up, the entire MainWindow.xib get loaded & I can see that this UIImageView has been loaded into memory. At this point, I have no need for this UIImageView.

When I need the UIViewController, I perform the usual alloc/init setup. At this point, when I look at this controller with the debugger, the controller is setup correctly, but the UIImageView that should have been pre-wired with Interface Builder is always nil.

Any suggegstions on how to make sure this UIImageView is loaded into memory correctly? This is the only case where I've had an issue with objects defined within this single MainWindow.xib file.

Answer1:

Assuming you have connected the view outlet, all you need to do is access the view property. When you look in the debugger, you're seeing the property's corresponding ivar. When you access the property in code, it should load for you. So, it should be as simple as:

[controller view];

Answer2:

Not quite sure I understand the problem, but instead of having the UIImageView in MainWindow.xib, why not have it in the xxxViewController.xib where it's actually going to be needed?

Recommend

  • UIView Subclass with a delegate using NIB
  • How to change splash screen in portable xamarin ios project?
  • Subclassing UICollectionViewCell and initialising from xib
  • Rewrite apply function to use recursion instead
  • How to redirect or show a page rather than “Forbidden” when i have directory listings off (htaccess/
  • Best approach for UITableViewCell with both a left and right label
  • CUDA Debugging - VS on windows workstation, GPUs on Linux server?
  • RegistryKey.GetSubKeyNames returns names that are not in that subkey!
  • Linking Ghostscript to pypdfocr in Windows Platform
  • Prevent page break in text block with iText, XMLWorker
  • Where these are stored?
  • Python 3.2.2, error(scripts to exe)
  • NSIS decompiler
  • Javascript/Jquery runs fast in desktop browsers, but slow in mobile/smartphone browsers…should I spl
  • Spark job failing in YARN mode
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • Multicolored edittext hint
  • Redux Form - Not able to type anything in input
  • Unable to get column index with table.getColumn method using custom table Model
  • Problem while Building a Setup Project for a windows Service?
  • How can I sort a a table with VBA with given text condition?
  • Transactional Create with Validation in ServiceStack Redis Client
  • Hardware Accelerated Image Scaling in windows using C++
  • Ajax Loaded meta Tags
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Android screen density dpi vs ppi
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • How would I use PHP exceptions to define a redirect?
  • How to extract text from Word files using C#?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • File upload with ng-file-upload throwing error
  • Benchmarking RAM performance - UWP and C#
  • Free memory of cv::Mat loaded using FileStorage API
  • Suggestions to manage Login/Logout transitions
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • need help with bizarre java.net.HttpURLConnection behavior