UISplitView question and issues - iphone

I created a new project with a UISplitViewApplication. When you do this you will find a DetailViewController and RootViewController. In the DetailViewController there is a UIToolbar on top that resizes according to the orientation, whether it's potrait or landscape. I accidentally removed this UIToolBar and I dragged a new one from the FileManager window, however after connecting everything this new one doesn't resizes according to the orientation. Why is this?
Also one more issue I am facing is related to this orientation stuff. I added a UITextField and UITableView, etc in this DetailView, however when switching in between the orientation everything is just messed up. How can I prevent this? How do I make my view consistent no matter what orientation it has...

Have you looked in the measurements inspector to see how the struts and springs are set up for the toolbar, etc? A lot of times, you can use springs and struts to control how your UI will react to orientation changes. Sometimes, you have to do it in code.
If you're not sure how to do that, here's a link with some good info on this subject.
http://www.techotopia.com/index.php/IOS_4_iPhone_Rotation,_View_Resizing_and_Layout_Handling_(Xcode_4)
Hope this helps.
Jamie

Related

iOS7 issue with container view

EDIT**: Although someone has decided they would like to down vote without a reason I'm going to leave this up. I noticed that in viewDidLoad of my view controller container, the content view I setup was the same size as in IB. When I later tried to load other views with my view container controller, the content view had changed it's bounds. Hope this helps anyone else that has a similar issue. The excepted answer worked. Since this is a build for iOS 6 a simple check of OS version made this an easy fix.
I have a strange issue that seems to be iOS7 related. This is an iOS6 targeted app. I have followed apples own docs about creating custom container views here. The problem I'm seeing in iOS7 is the first view I load is within the proper bounds of the content view i have defined, the other two are filling the bounds of the entire screen so it hides under the navigation bar with my segmented control. I defined the view I'm loading in a separate view controller in storyboards. Is there some sort of constraint that is working against me?
I should add that I have noticed the content view I defined in my container controller is actually changing it's size after the initial view is loaded. I'm at a loss of how to stop iOS7 from changing that UIViews frame size when it really shouldn't be changing.
Here are some screenshots. Code is pretty much the same as in the apple docs, have tried a few other ideas, defining bounds etc. but I think it has something to do with IB since the content view is changing its bounds. It appears to only be doing so in iOS7.
There is actually a proper way to fix this,
Set edgesForExtendedLayout to UIRectEdgeNone for the view under the tab bar.
Of course, I might've just looked at the pictures and assumed this was your problem...sorry if its completely unrelated..
That's a known 'issue' in iOS 7. Since you can now have a blurred look through the UINavigationBars, UITabBars, ... This also causes issues in native apps (e.g. the Photos App) or APIs.

UIButton images look fine in IB but get stretched when displayed on app

I'm developing an Enterprise app for tracking mileage and maintenance for company vehicles. I've added graphic buttons to snazz it up a bit. The buttons look the way they're supposed to look on the XIB in IB, and on the iPhone all other UIViews look correct, but on one particular UIView the graphic images are stretched way out of proportion vertically.
The first image below shows how it's supposed to look, with the three graphics buttons at the bottom. The second image shows how it's showing on the phone. The Help button on this screen cap shows normally, but it can't be counted on to stay that way.
It also is not consistent. Calling this view at any time may show the image stretched or it may not show an image at all. It rarely shows the image normally, like the Help button looks below.
The development phone is a 4S running 6.1.3. The views are set for the Retina 3.5 screen. XCode is the latest (whatever it is).
Again, it's only on this one view that the problem shows up. There is another UIView on the same view controller that is hidden when this UIView is shown. The button graphics on the other view look fine. All of the other views and view controllers use the same graphics on the UIButton, without any problem.
In Interface Builder (Xcode) you created the view using a 4.5-inch screen height.
But the device where you are seeing the problem is a 5-inch screen. So the view is resized to fit.
And when it does that, the autolayout constraints that Interface Builder put on those subviews take over to determine what they do. Those constraints are causing the heights to change.
No need to turn Autolayout off. Autolayout can be very useful, but it seems to enjoy randomly assigning the constraint "Align Baseline to:" to UIButtons after repositioning them.
Just select the UIButton/UIImageView in question inside Storyboard, locate the constraint "Align Baseline to:", tap the gear icon and select "Promote to User Constraint", and tap once more and select "Delete". This should solve your issue.
In response to the comments here, I will answer my own question: I turned Autolayout off for this view controller, and that fixed everything. This is the first app I have written since XCode has begun development for the iPhone 5, so I wasn't aware of the Autolayout feature. I'll need to understand how it works and why it did what it did.
Thanks for all your help!

Where are the methods that defines allowed orientations?

I've been working on my app for a while, and it've been out in appStore for a while as well, but I now want to add support for landscape orientation. I've thought I had just unchecked the orientation-icons in the Summary-page of the target to only enable portrait, but when I check them now, nothing happens! A lot of stash has been added, but I can't find any methods that should disable landscape.. What kind of method would that be? I didn't find anything in appDelegate either.. I don't even know where to start looking.. When opening an empty project in xcode, they orient just fine with no methods at all..
In storyboard, when clicking a view and going to inspector, it says Orientation:Inferred. So the problem isn't here.
I using a tabBar, and all the views in the viewControllers are set to Autoresize subviews, as a similar question got answered.
EDIT
When enabling landscape for iPhone using the buttons in the target properties summary, the iPhone is allowed to go landscape, but when enabling it for the iPad, nothing changes..
shouldAutorotate in iOS6 and shouldAutorotateToInterfaceOrientation for previous version.
Note that the orientation is mostly defined by the ViewController.
you can add or remove the supported orientations in info.plist
I solved the issue by making a class for the UITabBarController, and setting shouldAutorotate... to YES. I find it weird though that my iPad storyboard overrode the Summary-page.
EDIT
This is giving me a hard time with everything else.. The device rotates correctly now, but sometimes when launched in landscape, it thinks it's in portrait.. Still trying to figure that out. Even when I ask the app which orientation the devices statusbar is in, it returns portrait even if it really is in landscape..

How to trigger view rotation on new created view?

Simple question, hope there is a simple answer.
My scenario: iPhone app with NavigationController
Level 1: View with shouldAutoRotate..orientation=..Portrait (works)
Level 2: View with shouldAutoRotate..orientation=..Portrait (works)
When the iPhone is rotated, the views stay on portrait mode, perfect.
Level 3: View with shouldAutoRotate..TRUE (doesn't work on first load)
The first load of the view is in portrait independent of iPhone orientation and stays there, bad. After the view is ready, all rotations are recognized and work perfect.
Is there a way to tell the app "check your orientation now"? Several tricks I found didn't work (anymore) and the apple documentation seems less than helpful on this special topic.
So far the newest suggestion I found was to create a dummy view, show it and release it again, but I tried several places in the app and it didn't work. The view always gets stuck until you rotate the iphone manually. I would prefer a working example, so I can test it directly and see if it works before changing my code, but I'm also thankful for an explanation what to do if it works.
Thanks
//edit: As mentioned in one of the links this is considered a bug and not fixed by Apple, I worked around the problem replacing the NavigationController with own Controllers each with a Scrollview. Not very nice when you have all running and just need the rotation to work as expected, but works at least as expected. Thx to occulus for pointing in the right direction.
Please see this question:
Transitioning to landscape rotation within a uinavigationcontroller
Also:
UINavigationController and autorotation
So a good strategy might be to use Modal dialogs.

displaying a smaller UIWebView as a form sheet

I'm trying to pop up a UIWebView on iPad with a web site that is specifically sized for the iPhone (320x480). I want the web view to be centered, and transition in using a zooming animation. Other apps have this functionality, but I can't seem to find out how to do it. I've tried various combinations of presentation & transition style, but no matter what I do, the web view takes up the entire screen and slides vertically to cover the screen. I've made the web view 320x480 in IB, and am using UIModalPresentationStyleFormSheet, which should make it at least slide up into the center of the screen using a small window, but that is not occurring.
anyone know what's wrong?
Are you setting the property of the parent UIViewController or the modal UIViewController? Because you should be setting the properties of the modal UIViewController before presenting the controller instead of the parent.
This might be no help at all because you're doing the right thing, but it was the first error I made when starting to use MVCs.
maybe any of the autosize property is set. just do one thing bind your webview with the code and through code try to set the frame. Hope it will work as it worked many times to me when i faced similar types of problem.
hAPPY cODING...