iOS7 - content overlapping during push segue from table view - objective-c

Apologies if this has been asked before. I can't find any reference to this particular problem though.
I have an app which is basically a table view nested within a navigation controller. Each item from the table segues to a fresh view (via a generic push transition), containing some content within a scrollview. I have set this all up using storyboard for ease of layout.
When you click an item in the table, the intention is for the table to slide off the screen to the left and be replaced by the content view. This works fine in iOS 6, but since testing the app on iOS 7 I've noticed the functionality is different.
In iOS 7 the content view slides into frame as normal, but the table view only slides a little way to the left - still visible behind my new content. It disappears very suddenly after half a second or so, but the effect is very jarring as it creates a momentary overlap of two views.
This is only a problem because my content views have transparent backgrounds, but this is important to maintain for the effect I want. So just to be clear, my content view slides in over the top of the menu, which subsequently disappears. Looks very odd.
Any help on this would be much appreciated. I'd be curious to know the reason for this change and if there's a way I can fix it. Preferably by making the menu slide all the way offscreen again.
Thanks!

I had the same problem.
Try to add into target ViewController (that shows up after push)
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.backgroundColor = [UIColor redColor];
}
If all is ok you can change background to something like that
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"GreenBkg.png"]];
ps. tableView needs to be defined as #property in your .h filw

Related

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.

ios7 custom VC Transition: Overlap a Modal Form Sheet View

i want to use the new UIVC Custom Transition API in my iPad App Project. And i despair of it -.-. what i want to do, sounds very simple at first. My "FirstViewController" (simply the names) is a normal FullScreenVC. From that VC i open a "SecondViewController"modally with the default Presentation style Form Sheet. Everything allright. The SecondViewController is a normal UiTableViewController. So from inside the SecondViewController I want to open a "ThirdViewController" modally as well with a custom transition. This ThridViewController have to overlap the SecondVC with the Form Sheet Presentation and the content of the second view controller have to be dimmed as well. But i get many problems inside the animateTransition-method in the the Transition Delegate. My best idea by now is, making a UIView Snapshot of the from View. Create a new UIView with black background and alpha 0.5 and put it as a subview inside UIView Snapshot. Then transfer the frame and the center of the fromView to the toView and add the UIViewSnappshot as a subview to the toView and send it to the back. finally adding the toView to the containerView.
But when i do this, I get two s*** problems. The First is, that the Transition don't recognize that i am using a Retina display, because i put the center of the fromView to the the toView. But the toView dont overlap the fromView, better its nit at the same postion. Its almost at the left down of the screen and not in the middle of the screen. The second problem is, that the toView content seems to be transculent. In Storyboard and in code i write "be opaque and white bgcolor". But at runtime the see the controls of the view but the bgcolor is the bgcolor of the dimmed View behind it. Why?
At the moment i think i'm a dump guy :( What in hell im doing wrong?
Thanks
Avarlon

Trying to set a UIImageView as background - where is the Layout Menu item

I want to set an image as a setting's page's/view's background image. I have already created my Settings page and I have the image. I apply a UIImage View but I can't seem to set it as the background image in Interface builder.
Forum posts like this one:
http://forums.macrumors.com/showthread.php?t=715391
seem to imply there is a 'Layout' menu item that I can pick in IB and from there select 'Send to back'. But I can't find this anywhere in Interface Builder. Am I going nuts or has this been removed from the latest version of Xcode.
If it has, is there anyway within interafce builder to send my .png image as a background image for the page.
Thanks
...Dale
I am hoping that you are using a UIImageView as background image and inserting it into your view hierarchy. There are 2 ways you could do this -
1.From IB - Forget about 'Send to back', a simpler way to set your view hierarchy is -
here in the view hierarchy, mapView is topmost and the UIImageView is at the bottom most. IF you want to change this hierarchy all you need to do is drag the view and move them up or down. hope this is clear.
2.From Code - You can either insert it any where in your view hierarchy and push it all the way to the back with sendSubviewToBack: or you can make the UIImageView the parent view.
Another way you can use an image as a background, although it requires code, is to set the view's background colour to an image.
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *backgroundImage = [UIImage imageNamed:#"background.png"]
self.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
}
I wish there was a way to do this in Interface Builder.

Resize master and detail view controllers in a split view controller?

I'm working in Xcode 4.2 and am developing an app where I want the menu screen to use a Split View. Really, all I need the Split View Controller for is to split some of the menu options into a left pane and right pane. I want to be able to set custom sizes for the master and detail view controllers, but nothing seems to be working for me. I've tried updating the frame sizes for each view controller with code like:
[self.view setFrame:CGRectMake(0, 0, 768, 502)];
in the viewDidLoad functions, but that doesn't seem to affect anything.
Is there a way to set custom sizes for the master and detail view controllers of a split view controller without instantiating the view controllers in say the AppDelegate.m file? I want to be able to edit each of the view controllers in the storyboard as they are menu screens with a lot of buttons and such.
Edit:
In iOS 8+, the relative widths can be changed by specifying the minimum/maximumPrimaryColumnWidth properties or the preferredPrimaryColumnFraction.
The below answer is still true for iOS < 8:
You can't change the sizes for a split view controller.
See here: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html
"The UISplitViewController class is a container view controller that manages two panes of information. The first pane has a fixed width of 320 points and a height that matches the visible window height. The second pane fills the remaining space."
Use MGSplitViewController. It offers similar API to UIViewController, but offering additional features, such as split position, which is what you need.
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex;
{
return proposedMinimumPosition + 238;
}
- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex;
{
return proposedMaximumPosition - 200;
}
before the above delegate method add [splitView addDelegate:self];

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!