iOS7 NavigationBar visually grows from 44 to 64 points every segue - ios7

I'm working on an old code base written using Three20 (ack!). Now we need to be able to deploy this app to iOS7 and iOS6.
Mostly, it's working, but when the user taps and causes switching between view controllers, the navigation bar is drawn with a 44 point navigation bar during the transition animation, but when the animation finishes then it snaps to 64 points tall.
So, switch a view...smooth...butter...slam. Wash, rinse, repeat.
It's such a juddering effect when you switch from one view to another, on any iOS 7 iPhone-sized device. Interestingly, it only happens when switching from one view to another, not when switching to a new instance of the current ViewController.
I'd show code, but I'm not sure what code to show.
I'd appreciate any pointers at all (RTFM comments gladly accepted), my Google-fu has failed me this time.
View hierarchy looks something like this:
UIScreen
TTNavigatorWindow
UILayoutContainerView
UINavigationTransitionView
UIViewControllerWrapperView
UIView
TTTableView
UITableViewWrapperView
...and so on...
Is this a three20 problem where three20 assumed that Navigation Bars are always 44 points tall, but now they're not?
Is this an Interface Builder issue where the Navigation bars can only be created at 44 points, and I'm supposed to deal with this well in my code?
Is this an esoteric iOS 7 issue where it's decided that because the Navigator is at the top level, that it needs to change the height on a regular basis?
Is this a documentation issue where my (obviously meagre) powers of observation just didn't see the relevant bit in the Apple docs?
Thanks,
-Ken

First of all I would like to recommend to get rid of Three20. I know this is not very helpful for your situation, but really.
But then I would like to offer you two ideas on would could be happening:
Three20 indeed uses a hardcoded navigation bar size in various places, but I don't think this causes the problem you describe here. I may although pretty sure it causes Problem with iOS7 at other places.
From what you describe it sounds like the way iOS7 calculates the navigation bar height might be the problem. Of cause that would somehow inferrer with how three20 manages view, cause it works ok for plain UIKit. What happens if you move your whole view stack 1 px down, towards the bottom of the screen? I guess, that the navigation bar does not change it's size then. To understand that take a look at how iOS7 calculates the navigation bar height. I guess what you would like to have is the 64 px navigationbar throughout the whole animation. I'll have to figure out how to modify the frame of the view controller being presented before the animation to achieve that effect.
I hope some of this ideas can be helpful.

Related

iOS 7 + Auto Layout: Strange UIImageView behaviour

I've got a strange UIImageView behaviour:
I've got a UIViewController with an embedded UIImageView and a close button. Very basic stuff, done a thousand times. I didn't use Auto Layout that much in the past, but another view controller in the same Storyboard has nearly the same config and doesn't appear as strange as this specific one.
In my Storyboard the Controller looks like that:
...and on the device it looks like that:
That image is 1024x768, so it should be filled to the bounds. Content mode in the image view is Aspect fill. When i dismiss the view, i can see that the upper part of the image view must be hidden at the top with some negative Y or something.
I need Auto Layout in this storyboard, because it's an iPhone + iPad App with both orientations.
Has someone hat a behaviour like that before?
Thank you!
Edit:
Here is the layout panel:
First, get rid of the alignment constraints, they are not needed if you're already anchoring your view to every side with a set distance.
Second, check the mode property of your UIImageView in the interface builder. If the image was not big enough and you had it set for "TOP" instead of, say, "aspect fill", you'd see something like this even though the view is actually covering the whole screen.
I'm sorry that I have to say this, but it was, as you certainly thought, my own fault.
The problem was that I made a photo with the iPad, and the iPad can be used in both orientations in this app. The photo was taken and was then used for an own view that allows the user to put annotations on the image.
The image gets then saved, and that was were the problem occured: I call
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
The landscape image was now taken into a portrait frame. After adjusting this and only allowing portrait mode, everything worked well.
Thanks anyways for your answers. And sorry for asking a question when the problem was another one and my own fault.

iOS 7 - Make UINavigationBar extend to top of the screen

I'm new to making apps for iOS and this problem has been bugging me for hours now.
The navigation bar in the modal popover view (on the right) doesn't properly extend to the top of the screen, like it does in other apps. I know that I could just disable Autolayout and do something like CGFloat newheight = self.InfoNavigationBar.frame.size.height + 20;
[self.InfoNavigationBar setFrame:CGRectMake(0, 0, 320, newheight)];, but I'd like to do this with Autolayout enabled, if at all possible.
Right now, the view looks like this when viewed on my iPhone:
How can I make it properly extend to the top of the screen, leaving the status bar on top of it? It'd be nice if this could be done in IB, without having to resort to doing all this in code.
(Edit: A few other iOS-related questions on SO suggest that IB and Storyboards are two different things. I don't even know which is which, take a look at the first screenshot, I'm using whatever that is.)
Apparently it's sufficient to override your UINavigationBar's positionForBar method like so: https://stackoverflow.com/a/18968920/1058399 It still feels like a dirty hack, but until there's a better way, I'll be doing that.
Edit in case any newbies like me read this:
All of this falls apart when you want your app to support landscape modes. Navigation bars are supposed to be smaller in landscape mode, which is done for you automatically if you wrap your view in a Navigation Controller. Don't just place navigation bars and expect them to "just work".

Storyboard editor layout confusion

I am having layout problems with the storyboard editor with a fairly simple screen. I have a UIViewController to which I have added a 320x440 UIScrollView at 0,0 followed by a 320x20 UIProgressBar at 0,440. It looks fine in Storyboard editor. I'm not entirely sure how the 20 pixel status bar at the top of the screen is accommodated given the CGRect frame coordinates that Storyboard calculates.
On loading ( in -(void)viewDidLoad ), the UIScrollView frame seems to be set to 320x460 pixels at 0,0 but the UIProgressBar is still 320x20 at 0,440.
When I add subviews to the UIScrollView, (UIImageViews in particular), they get stretched and get clipped on the screen because although the UIScrollView thinks it is 460 pixels high, it only has 440 pixels of screen to display in.
Can anyone point me to a solution?
Thanks
OK - I have identified what was going on - there were a number of issues, nearly all to do with mutually incompatible settings in storyboard attributes on various view controllers.
In summary, the main view controller containing the UIScrollView had the 'wants full screen' checkbox ticked - goodness knows how, but it appears that I had then gone through other views trying to compensate for that initial error by clipping, resizing, setting layout constraints etc. which resulted in rather confusing outcomes.
My advice would be to not touch ANYTHING in storyboard editor unless you know what it's effect will be - it is a dangerous place. I found the issue by going back to basics and creating a trivially simple replication of my app and then observing the differences between that app and my own. Sorry if I wasted anybody's time researching an answer.
Thanks

A UITabBar like this

I wondering how I can make a UITabBat like this:
The height of this is more than the stand UITabBar and also the icons are larger. Also the arrow on top.
I tried changing the height but it looks really bad. The icons aren't centred vertically. Also I couldn't change the background.
Thanks.
I'd suggest several things;
Check out the core animation videos from this years wwdc, you can use it to create effects like the triangle and move it back and forth. Then write your own tab bar controller class.
you could also consider a third party library like http://cocoacontrols.com/platforms/ios/controls/tabbarkit

Rotating MapView according to compass

I'm working on Map application that needs to work like original MapView on iOS.
I need to rotate mapview according to compass heading value. I tried MTLocation example also I also tried this answer But my results is not good.
Please see the screen shot.
When I rotate mapview according to heading value Map is rotating but as you can see on screen tiles is missing.
How can I solve this display problem ?
Regards
- Fatih
Hy,
I'm the author of MTLocation. Thanks for using it by the way!
For this to work you have to make sure, that your MKMapView is a subview of your ViewController's view (and not the view itself). Then you have to increase the frame of your mapView with a simple Pytaghoras - calculation: the width and height must be at least as big as the diagonal: sqrt(visibleWidth[320]^2 + visibleHeight[480-88]^2) = 506.
So that means
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(-100,-100,520,520)];
Hope that helped, please consider upvoting if it fixed your problem.
You can consider using a bigger frame for the MKMapView object. It should probably be a square with each side equal to the length of the device's diagonal. The problem with this approach is that there are regions of this object that the user won't see but we process information like views for annotations related to that region anyway. Other properties like visibleMapRect would be least helpful.
Another alternative would be to be zoom in by scaling the MKMapView object on rotation. But this might make the map blurry (untested). You could zoom out on the region displayed in the map but it could lead to frequent refreshes. You can look at a middle ground where you don't zoom out until the map is rotated over a certain angle. You can also look at using two views where one of the views is off screen and updated so that it can replace the view after a certain amount of rotation so that it feels seamless.
I am working towards making my own maps application in iPhone. I want my maps to rotate as the user turns. I tried setUserTrackingMode available in iOS 5, but due to some reason it doesn't work. So I decided to take help of MTLocation framework here.
Till now I have done the following.
created a new project and copied all .m and .h files in that.
Import MapKit.h and MTLocation.h.
In Viewcontroller.h, defined property for mapView (should I define a property for locateMeItem).
In ViewDidLoad, paste the code given at the end of the page here.
I get a few errors:
Can't see the locateMe button when created programatically.
Undefined property headingEnabled.
myCustomSelector has no effect.
self.toolbar- toolbar is not a instance of ViewController.
I have tried a code at gist[dot]github[dot]com/1373050 too, but I get similar errors.
Can anybody explain a detailed procedure of this.