IOS7: Pop ViewController forces the UIImageView to drop - ios

After upgrading my project to iOS7
when I do a BACK Button and the UINavigationController goes back to the previous page, an ImageView on the top of the screen shifts down.
I use IB to do my layouts. These are my Simulated Metrics:
I have AutoLayout off. Any ideas on what the issue might be? I wasnt sure if anyone wants to see specific code and I didnt want to clutter up the question with too much code.
Updates: Based on the comment questions, I wanted to make these updates:
In no place in the application .h or .m file do I make any changes to the imageview's sizes or location.
In both the viewDidLoad and viewDidAppear I call a user-defined method called recalculateAll but their is no reference at all to any imageview sizes. Just for trying it out I commented out the entire section and ran the code and it still jumps down.
In my init I do programatically set some imageviews (you see the #132 in what appears to be a bubble) using their x and y's.
Here is a typical navigation I use for moving from the view controller to the tableviewcontroller:
GetTimeOffByType *showTimeOffReport = [[GetTimeOffByType alloc] initWithNibName:#"GetTimeOffByType" bundle:nil];
showTimeOffReport.timeOffType = #"Vacation";
[self.navigationController pushViewController:showTimeOffReport animated:YES];
These are all .xib files, no storyboarding at all. Its basically a view controller which has an embedded UINavigationController with 6 buttons. Each time a button is pressed it pushes a UITableViewController passing different parameters and showing different data. The transition I am using to get back to the original UIViewController is simply the iOS generated BACK button (so no code to show for that)
Update#2 Hopefully this will help someone solve this wierd behavior. So if I were to click on the table view cell on showTimeOffReport to get the cell detail and then using BACK navigate all the way back it doesnt jump down.
Update#3 Ok this is something I just discovered : The issue of jumping down or not is related to the translucency of the UINavigationBar. If you have a Translucent = YES it will start from the top of the window. If you have a translucent = NO it will start from the bottom of the UINavigationBar.

You might try setting the new property on UIViewController edgesForExtendedLayout to UIRectEdgeNone.
Here is a good resource that explains more about how view layouts changed in iOS 7.
See Apple Documentation
If you plan to be backwards compatible you will probably need to do some runtime checks and adjust positioning if the device is not running iOS 7.

This might help you..You can try adding UIViewControllerBasedStatusBarAppearance key and set it's value NO in your info.plist
UIViewControllerBasedStatusBarAppearance = NO

Related

Second pushed View Controller with UISearchController doesn't receive touches in UINavigationBar

I modified AAPLSearchBarEmbeddedInNavigationBarViewController in Apple's UICatalog sample code so that it pushes another instance of AAPLSearchBarEmbeddedInNavigationBarViewController onto the navigation stack when a cell is selected. In the second view controller the UISearchBar set as the title view of the UINavigationBar (just like the first one) isn't tappable (unlike the first the one). This seems like a bug. How do I fix it? Here is my modified UICatalog code:
https://github.com/stevemoser/UICatalog
Also I tested with with Xcode 6 and 7. It's broken in both.
The solution is to set the first VC self.definesPresentationContext = NO when navigating away from it and making sure to call self.definesPresentationContext=YES in the view did appear so that the visible VC allows defines the presentation context.
Thanks goes to Rory McKinnel who put me on the right track.

Loading controller on top of view from storyboard (or nib if necessary)

I've seen lots of topics about this but i could not get this to work as i wanted, i'm sorry that this will look like a duplicate.
What i'm tyring to do :
Show a view from a storyboard VC (or a .xib, it's really up to what's "best") as if it was an alert. The user has to interact with it and then dismiss it.
Here is what i have :
A viewcontroller in my storyboard ; its linked to the corresponding .h and .m files and everything works fine on that side.
Note : That viewcontroller is "alone", there is no segue leading to it.
Now i'm in my active VC from my app flow, and i'm doing this :
ADFViewController *adf = [[ADFViewController alloc]initWithNibName:#"ADFView" bundle:[NSBundle mainBundle]];
adf.xxx = yyy // just setting some data that the user interacts with.
[self.view addSubview:adf.view];
(The VC has a button that does [self.view removeFromSuperview]; to dismiss itself when the user decides to do so.)
I've also tried using this :
adf = [self.storyboard instantiateViewControllerWithIdentifier:#"ADFViewController"];
Both don't work or "almost" work.
They're linked like they should, the storyboard and Nib name corresponds (i've tried both).
As a result I just get a blank screen. The view size is 300x300 so It should at least appear somewhat on my screen. But all i get is a blank screen (the view background).
When that is working, I intend to make the background transparent so it really looks like an alert but i'm not even up to that point. And maybe i'm struggling even though i'm going in the wrong direction.
Questions :
Am i doing something wrong?
Is this the right way of achieving this?
What should I do?
Thanks a lot for your time.
Getting a view to look and behave like an alert (with the transparent background, etc.) takes some work because you can't subclass UIAlertView. I would recommend using an already-built customizable UIAlertView-looking dialogue. There are a couple listed on this question:
UIAlertView addSubview in iOS7
These basically just take a view as input, so you can just pass in your view controller's view and everything else will be taken care of for you.

Top half of UINavigationBar on iOS6 not responding to taps

I'm working on an iPhone app and have the strangest issue.
On iOS 6, buttons on the navigation bar are completely ignoring taps in the top half. Have a look at the image below, I have roughly selected tap areas of my navbar buttons:
https://www.dropbox.com/s/izs6ic5jlubm1yk/navtap_problem.png
Here's some, potentially useful, information:
the app supports iOS 6 and 7
the app is not using autolayout (working with deltas instead)
this issue is present only on iOS 6, it's working fine on iOS 7
the issue is present in all views across the app (that have a navigation bar on top)
the issue present in both navigation bars that are manually added in IB as well as in navigation bars that are coming from the UINavigationController
the problem is not present if I directly start the app from one of affected view controllers
the problem is present when I start the app through my empty InitialViewController and load another VC
I'm using ECSlidingViewController and loading the real VC (that users will see) from the InitialViewController like this:
self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"SearchSplitViewNavigationController"];
[self resetTopView];
It looks like something invisible is covering the top half of the navigation screen. I checked the contents of self.view.subviews, but didn't see anything there.
Any ideas what might be causing this? Or what else could I check?
If you are including any element programmatically, then that element isn't using the deltas you are including through the storyboard.
For these elements you must test for the iOS version you're in and adjust the delta in code.
Check this: Best Way to check for iOS 7 or earlier? for help on the version checking.
I've found a solution (not the cause though). This awesome library helped me a lot to identify the problem.
There was actually a transparent UIView sitting on top of my navigation bars. It was located at 0,20 and had a height of 20 points.
That view is not in the self.view.subviews array, but doing [self.view bringSubviewToFront:myNavigationBar] seems to do the trick...

View drops 20 pixels when build against iOS 6 SDK in Xcode 4.5

After building my iPad app against iOS 6.0 SDK, I get this weird behavior with my UISplitViewController's detailed view. The detailed view is positioned 20 pixels (points / 40 pixels) lower than it should be.
Here is what it looked like under 5.1:
For DetailViewController_iPad.xib in Interface Builder I've set the Simulated Metrics > Top Bar to None. This didn't help.
I've logged the view frame:
- (void) viewDidLayoutSubviews {
//.. etc
NSLog(#"viewDidLayoutSubviews: %#", CGRectCreateDictionaryRepresentation(self.view.frame) );
}
This logs the height as 684 instead of the what it should be: 704.
Height = 684; Width = 703; X = 0; Y = 0;
Anyone have any experience with this sort of thing? What should I try next?
UPDATE: This problem seems intermittent, with some compiles causing it, and some not.
If anyone else has had this problem and found out what causes it, I'd still be keen to know.
I had the exact same issue!
The issue will occur when there is another view controller in the navigation controller and this split view controller is pushed in the method application:didFinishLaunchingWithOptions: during app launch.
This fixed the problem for me:
When pushing the splitViewController I used
dispatch_async(dispatch_get_main_queue(), ^{
[self.navigationController pushViewController:splitViewController animated:NO];
})
instead of
[self.navigationController pushViewController:splitViewController animated:NO];
I used this only for iOS6 otherwise first view will be momentarily showed in OS < iOS6.
I'm assuming you're not doing anything to effect the frame of the view in code, correct? It's the view's controller that's doing all the layout? If so, have you tried tinkering with -wantsFullScreenLayout?
When a view controller presents its view, it normally shrinks that view so that its frame does not overlap the device’s status bar. Setting this property to YES causes the view controller to size its view so that it fills the entire screen, including the area under the status bar. (Of course, for this to happen, the window hosting the view controller must itself be sized to fill the entire screen, including the area underneath the status bar.) You would typically set this property to YES in cases where you have a translucent status bar and want your view’s content to be visible behind that view.
If this property is YES, the view is not resized in a way that would cause it to underlap a tab bar but is resized to underlap translucent toolbars. Regardless of the value of this property, navigation controllers always allow views to underlap translucent navigation bars.
The default value of this property is NO, which causes the view to be laid out so it does not underlap the status bar.
Mind you, -wantsFullScreenLayout should really only effect a window's root view controller. So if this fixes your problem (and you're not doing anything goofy with your view controller hierarchy), please file a bug with Apple!
Maybe [UIViewController statusBarHidden] is set to NO on your detail controller?
Xcode 4.5 has a habit of applying autolayout, which may be the cause of some of your grief - inspect this and trying deselecting it.
have you set autosizng property of height in xib file or programmatically, if yes try removing them and see if it helps the problem.
May help.
I was also affected with same issue i had just reduce size of view in my example:
I have 480px height in XIB for iPhone Apps and i reduce it to 460px.
Please same do for iPad not sure but may help.
I got the same problem when i tried to present another viewcontroller in ViewWillAppear method. I got it solved by moving my presentViewController code to ViewDidAppear method. Hope it will help.

Adding UIViewController.view to another view causes orientation problems

Short version:
I'm alloc/init/retaining a new UIViewController in one UIViewControllers viewDidLoad method, adding the new View to self.view. This usually works, but it seems to mess up orientation change handling of my iPad app.
Longer version:
I'm building a fairly complex iPad application, involving a lot of views and viewcontrollers. After running into some difficulties adjusting to the device orientation, I made a simple XCode project to figure out what the problem is.
Firstly, I have read the Apple Docs on this subject (a small document called "Why won't my UIViewController rotate with the device?"), and while I do believe it has something to do with one of the reasons listed there, I'm not really sure how to fix it.
In my test project I have an appDelegate, a rootViewController, and a UISplitViewController with two custom viewControllers. I use a button on the rootViewController to switch to the splitViewController, and from there I can use a button to switch back to the rootViewController. So far everything is great, i.e. all views adjust to the device orientation.
However, in the right viewController of the splitViewController, I use the viewDidLoad method to initialize some other viewControllers, and add their views to its own view:
self.newViewController = [[UIViewController new] autorelease];
[newViewController.view setBackgroundColor:[UIColor yellowColor]];
[self.view addSubview:newViewController.view];
This is where things go wrong. Somehow, after adding this view, adjusting to device orientation is messy. On startup everything is fine, after I switch to the splitViewController everything is still fine, but as soon as I switch back to the rootViewController it's all over. I have tried (almost) everything regarding retaining and releasing the viewcontroller, but nothing seems to fix it.
As you can see from the code above, I have declared the newViewController as a property, but the same happens if I don't.
Shouldn't I be adding a ViewController's view to my own view at all? That would really mess up my project, as I have a lot of viewControllers doing all sorts of things.
Any help on this would be greatly appreciated...
I had the same problem, seams resolved by removing from the parent view the "autoresize subview" option in IB.
Select the view a then: Inspector -> Attributes (first tab) -> drawing.
What I think is happening is that your new viewcontroller is getting the autorotation calls and probably not handling them. Meanwhile your old viewcontrollers and its views won't get the autorotation calls and will be stuck in whatever orientation they were in.
I can't tell, but I think what you want to do is to make a UIView and add it to your old viewcontroller, instead of making a UIVIewController and adding its view.

Resources