iOS9 - UITableViewCellContentView is covering up Controls inside Cell - objective-c

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.

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.

right detail of static tableview not visible in IOS 8

I have a static UITableView. Some cells are set to right detail.
I made UILabel IBOUTLETS for all the right labels and connected them in storyboard. In my viewWillAppear I set the text of the UILabel.
Here is the problem. When my view apppears my text on the label is not visible. But when I touch the cell. The label becomes visible.
This is an IOS 8 problem only. Can someone help me with this.
Kind regards!
There is some bug in Interface builder in Xcode 6.
Change Style of Table View Cell in IB to Basic and then to Right Detail again.
It should work then.

Does UIActionSheet reload the main view when it's called?

I have a UITextView in my view and I have a drag and drop ability for users. If I move the UITextView using the drag and drop and then I activate the UIActionSheet it will automatically move the UITextView back to where it was located originally in the StoryBoard. I've traced through this and it moves this object before the willPresentActionSheet and didPresentActionSheet delegate methods are called. Any thoughts?
Ok I figured out the issue. I had Auto Layout enabled and so for some reason when you pull up an UIActionSheet it treats it almost like a rotate screen and activates an auto layout. I disabled that and it worked fine.

Strange UIImageView issue

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).

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!