upgrade to universal app - size of mainWindow-iPad is 320x480 - iphone

I have the following problem.
I have an iPhone app and want to upgrade to universal
When I do this, I get the expected MainWindow-iPad.xib.
But the size of the window is hardcoded to 320x480.
Also, there is no view in the window.
I red, this should be automatically iPad-sized, so I am assuming I am doing something wrong.
What exactly am I missing ?
thanks in advance

Yes, the dimensions of a UIWindow object are hard-coded to the size of the iPhone screen. This confused me, too, until I realized there was an option to resize it: select the UIWindow object in the .xib in Interface Builder... in the Attributes pane, make sure the "Full Screen at Launch" checkbox is checked.
As St3fan says you'll probably want to have a specific main window .xib for your iPad build.
See my answer at:
UITabBar unresponsive on iPad

I got this. I fixed it by deleting the automatically created ipad xib, then opening the original xib in interface builder and choosing convert to iPad from the menu. Then ni saved it with the -iPad name and added it to the corredt target.

You will probably also need to create a MainWindow-iphone.xib and MainWindow-ipad.xib.

I had a similar issue with a GLES application - using EAGLView, in a manner similar to all of the samples, but wanting to support iphone3,iphone4,and ipad.
in my context creation from [EAGLView initWithCoder], I was forcing the eaglLayer's rect to match the main screen, which worked for iphone and iphone4 (i.e. gave me a 320x480 or 640x960 gl surface), but for ipad, this gave me a 768x1024 surface which was cropped on present to 640x960.
As it turns out, The "Full Screen at Launch" option seems to be applied AFTER the view's (EAGLView, in my case) initWithCoder.
My solution was to do nothing in the [EAGLView initWithCoder], and only actually initialize my view after the AppDelegate's didFinishLaunchingWithOptions gets called, in the layoutSubviews call.
HTH,
forks

Related

Size of UIView object in Interface Builder changes when using the app

I have an extra UIView object that I just dragged onto the storyboard. It covers the entire iPhone screen. So I clicked on it and dragged it until it only covered half of the iPhone screen.
This is what my storyboard looks like with my extra UIView object selected:
However, when I actually use the app on my iPhone, the UIView is much smaller and doesn't even take up half of the screen(It's the square with the stackoverflow site image inside of it):
How can I keep it from being smaller when I actually run the app? When running the app, I want the UIView object to be the same size as it is on the storyboard in xcode.
Thanks for the help.
You must have selected Autolayout. Uncheck it and problem is resolved.

GUI elements position in Xcode Storyboard differs from their position in the simulator

I recently worked with Xcode, especially with layout GUI elements. I read a lot of questions here about this, but it did not help me. What I have: ViewController, it lies ImageView, it lay all the other elements, I disable autolayout, screen size and in the simulator and in Xcode - the same (4 inches), but when I run I still see it:
What am I doing wrong, what is there is a way to what looks like a storyboard, and looked in the simulator (and real device) equally?
There might be two issues you are suffering with, please check following points for better understanding.
Check this with iOS 6 simulator. If its working fine then, you need to set ios 6/7 deltas for your subviews. Here is better explanation of it-- Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
Check autoresizing masks of your subviews, definitely this is what affecting your views.
Good Luck!
Notice that in your Storyboard view, you have not displayed a status bar and that when running on the simulator, a status bar is shown. This is why all the objects are off placed. To fix this, you can either:
Hide the Status Bar - Call this method in your desired view controller:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Show a simulated metric - Switch on the status bar simulated metric in your Storyboard:

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

UIPickerView Causing Crash in iOS4

I have a simple tabbar app. Built directly from the tabbar template. As I test the app, I notice that the app sometimes crash. After pinpointing the right sequence, I found out that the app will crash if I do this:
Run app. Open the view that has a UIPickerView on it.
Open another view.
Tap home button (this will send the app to background).
Tap the app icon again to bring it at the front.
Tap the view that has the UIPickerView in it.
Crash!
Checking the console shows:
-[UIPickerView setFrame:]: invalid height value 130.0 pinned to 162.0
The UIPickerView I use is a custom size. I use transform of scale 0.8f on the height. So if you calculate 0.8*162.0 is indeed 129.9f (130 as mentioned by the console).
I have no idea how to fix this. Any ideas?
The problem is solved. It seems when the app goes to the background, UIPickerView needs to find its components resources again. It is not about sizing of UIPickerView at all.
I used images for the UIPickerView components, so after I populate the UIPickerView with these images, I released all the images that were allocated earlier. These images must not be released if it were to work in iOS4.
Only release them when the app ends.
Your problem has been fixed by another guy with a radical approach. See this post'sanswer provided by a guy named bhavinb.