Strange UIImageView issue - objective-c

I added a UIImageView to my View Controller's main view using interface builder.
Then I just set the image of the UIImageView in the properties.
When I run the app I can't see the image. What can be wrong? Thanks
PS. On the XIB file, if I select the image, I can see it - once I remove focus
from it, it seems like it went to the "back" of the main view (because it is still there, I can see it in the "Objects" window of the XIB file).
pps. It works if I use a different image. Could it be that it was because previous image was with transparent background? (although it still had some icon).

Related

Autolayout works when viewController is loaded from XIB but does not work when loaded from Storyboard

I Have a project here. Autolayout constraints is working only when loaded from a Xib file.
When you run the project you will see a single screen with a NSPagecontroller on it that has two views (swipe left/right to get the other view).
Both views are exactly the same with the exact same auto layout constraints on it. One is loaded using Xib, while the other is loaded using Story board.
Try resizing the window when the xib loaded one is on screen. You can see every thing resizes correctly. Now swipe the screen left. Try resizing the window now. The view loaded from story board will not autosize.
Is this Apple bug?
The views are not exactly the same. If I delete the view in the storyboard, and copy-paste the view from the xib, then the storyboard version behaves as expected.
The trouble with all of this storyboard/xib constraints goodness is that they are a complete pain to debug if something goes wrong.
Try spot the difference:
(1) ViewController.xib
(2)Storyboard
For this reason, I tend to handle all of my constraints in code these days.
Top left button comparison:
(1) ViewController.xib
(2)Storyboard
The other buttons constraints differ also.

iOS9 - UITableViewCellContentView is covering up Controls inside Cell

I have made a custom UITableViewCell called "SwitchCell" that has a switch.
In iOS9 Only, using Xcode 7 beta, the Content view in the cell is on top of the switch. (See screenshot of View Hierarchy. You can clearly see that the content view of the cell is on top of the other views. ):
So all the touches to the UISwitch are intercepted, and the IBAction does not fire.
In iOS8, this is not a problem. See screenshot for iOS 8.4 simulator. You can see that there is no content view on top of the controls:
Has anyone had this problem?
I tried remaking the NIB from scratch, but the same result occurs.
My NIB is a freeform size view with No status bar. It has two outlets: one for UILabel, one for UISwitch.
EDIT: please make sure to check the answer below that asks to verify that the cell's root view is not just a UIView but a UITableViewCell. This issue may also be a side effect of this.
After more investigation and searching, i found my solution here:
Button in UITableViewCell not responding under ios 7
What fixed it for me was:
cell.contentView.userInteractionEnabled = NO;
This prevents the cell content view from taking over the touch events, even though it's on top of the other views.
This issue was not only happening on iOS9, but on iOS7 as well. In iOS8, the Content view was behind the controls.
Problem can be in .xib file for your cell. When you create cell in separate .xib, be sure to drag UITableViewCell on canvas, not UIView.
SWIFT
I had an issue where my buttons in my custom tableviewcell swift files were working just fine, but then I upgraded to Xcode 12 and then all of a sudden I couldn't access them anymore (meaning my taps were not being recognized). The cell content view seemed to be interfering in the hierarchy and this like saved me:
cell.contentView.isUserInteractionEnabled = false
I put the line in cellForRowAt.
Thank you to #FranticRock
I had this problem when I was reusing a cell as a .xib. I didn't realise but when I first created the xib the default view that it created was in fact a UIView and not a UITableViewCell. It seems that at some stage UIKit adds the content view on top of my other elements and therefore interrupts certain events (e.g. touch events).
I resolved this by opening my xib file and dragging a UITableViewCell onto the canvas and copying my UI elements from the old view to the new cell.
Afterwards, additional settings also became available in the attributes inspector that matched those for a UITableViewCell.

What is the proper way to deal with changing a single UIView within a storyboard scene

Lets say I have a scene which includes a UIView container on the top half of the screen, and a UIView container on the bottom half of the screen and a few buttons at the very bottom of the screen.
Basically the bottom container will always display static text while the buttons across the bottom will change the content of the top container which may include an image, more buttons, or more text depending on what button is pressed on the bottom. Also each time a bottom button is pressed the top container is transitioned to the new view with a flip from bottom transition.
I have achieved this purely programmatically, but decided to convert my app to a storyboard file since it makes producing the rest of my app much faster and simpler, plus makes the code not look like a crazy mess.
My limited understanding of storyboards seems to deduce that I would need a separate story board scene for every UIView change, and Apple's coding conventions with storyboards seem to imply that we should use a new ViewController every time you create a new scene. All this adds up to an even bigger mess than I currently have.
Is there a better way of doing this? Am I misunderstanding something? If I am not confused, is there some way to make all these scene and view controller duplication cleaner?
The storyboard editor makes it difficult to do what you're describing, because it doesn't let you edit freestanding views associated with a scene.
I suggest you just create a separate nib (not storyboard) for each of the top-half views. These can exist separate from your storyboard. Your view controller (which is instantiated from the storyboard) can then load whichever nib it needs when a button is pressed, and put the view from the nib into its (the view controller's) top-level view.
There must be a way!
I accidentally opened one one day (see attached image). Although I have no idea how I did it and really really want to know, I cannot reproduce it, nor close it. The UIView opened when I was dragging my connection for the table header view from the Connections Inspector to the list of controls on the left side of the screen (not to the actual UIViewController).
I too am reworking a project with storyboards and have a similar problem with multiple views per UIViewController.
In this case it is a table header. I have other UIViewControllers in the project with the same configuration but I cannot get them to pop up either.

UIImageView in PopOver not changing?

I'm making an app and it has multiple button that when you press them it open a pop over view (using Storyboard.) The image is blank in IB (I set it that way) and my buttons are ment to populate the image view. This is the code I'm using:
[popoverImageView setImage:[UIImage imageNamed:#"telegraph.jpeg"]];
Steps (in order run)
Popover opens
Above code is run
Some notes:
The image is case matched.
The image is built-into the bundle
Anyone able to shed some light?
if you haven't read Apples View Controller Catalog for iOS you should read it.
I would check your popoverImageView's viewDidLoad/viewWillLoad and see if it is clearing your View before it presents itself.
Check your popoverImageView's properties they may not be linked properly
Enjoy using the storyboard I find it a pain for Popover's
Without any information regarding the the interface for your Popover and the implementation of the function where you call [popoverImageView setImage:[UIImage imageNamed:#"telegraph.jpeg"]]; and your setImage function i can't be sure of your exact problem

Why isn't my tableview visible?

I'm an sdk newbie, so please forgive the simplicity of this question. Here's the scenario:
I used the Utility Based application template because I like the flip effect of the info button. I changed the info button to a round rect button and made a copy of it that to have two round rect buttons on my first view. I modified the flipside view to display a picture and that functionality works fine. For the second button I wanted it to flip to a tableview underneath the navigation bar. I added a navViewController for the navigation bar and a TableViewController for the tableview. I made a nib for that View, added the tableview, hooked up all the appropriate connections, but when I run it, the flip works fine, but there is no tableview displayed. What I mean by no tableview is it is blank. No lines or anything, just a blank navigation bar at top and blank white space. Please help! Thanks!
With limited information you have given here:
Potential Problem 1 - First Level UIViewController is not linked
If you open NIB file in interface builder where you have drag and dropped NavigationViewController, you will see small disclosure triangle. If you expand that you will see NavigationBar and UIViewController. Select the UIViewController and change it to name of the TableViewController.
The NIB file will change and say View Loaded from YourTableViewController.
Potential Problem 2 - You have to do addSubView or insertSubView and pass in [navigationController view]
If you post some code it may be helpful.
Hope this Helps!