iPhone app has stretched in the iPad - ios

I want to test an iPhone app on the iPad, but I only have iPad now. IOS5.1 & Xcode 4.3.1 that are my environment and I set the same storyboard in the project TARGETS, the app runs on the iPad has been fullscreen displayed (all of the UILayouts have been stretched), cannot show any view switch in the app.
How can I run the same size app on the iPad?

You need to change the app target from Universal to iPhone.
Go to [Project Targets] > Summary > iOS Application Target > Devices > iPhone
This way the iPad will open your app as a legacy iPhone app.

Not sure how to do this with storyboards but with normal UIViewControllers you would have seperate xib files for iphone/ipad and check which one to load like so:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.motionJpegViewController = [[MotionJpegViewController alloc] initWithNibName:#"MotionJpegViewController_iPhone" bundle:nil];
} else {
self.motionJpegViewController = [[MotionJpegViewController alloc] initWithNibName:#"MotionJpegViewController_iPad" bundle:nil];
}

Related

iOS - App Rejected Because Of Guideline 2.10 - Resolution For iPad - How to Fix?

My iPhone only app has been rejected for the following reason provided by Apple:
We noticed that your app did not run at iPhone resolution when reviewed on iPad running iOS 9, which is a violation of the App Store Review Guidelines.
I now understand that the iPad has its own iPhone simulator that you can run iPhone apps on. After initial debugging, I noticed that, when testing on the iPad Air (iOS 9.0), my iPhone 5 storyboard is being used in its own iPhone simulator.
This is how it looks (correctly) on the iPhone 5:
http://i.stack.imgur.com/SMHyx.png
And this is how it looks (incorrectly) on the iPad:
http://i.stack.imgur.com/2PHG4.png
Since the iPad is using my iPhone 5 storyboard, why isn't it scaling everything correctly? How do I fix this?
*****EDIT*****
I have discovered that I made a mistake when debugging and the iPad's iPhone simulator has a display height of 480, which is the size of an iPhone 4. My code below was causing my iPhone 6+ storyboard to be shown:
CGSize result = [[UIScreen mainScreen] bounds].size;
//get the right storyboard for the device.
if(result.height == 568)
{
storyBoard = [UIStoryboard storyboardWithName:#"iPhone5" bundle:nil];
NSLog(#"IPHONE 5 STORYBOARD!");
}
else if(result.height == 667)
{
storyBoard = [UIStoryboard storyboardWithName:#"iPhone6" bundle:nil];
NSLog(#"IPHONE 6 STORYBOARD!");
}
else //iPhone 6+
{
storyBoard = [UIStoryboard storyboardWithName:#"iPhone6Plus" bundle:nil];
NSLog(#"IPHONE 6+ STORYBOARD!");
}
However, I thought I made my app for only iPhone 5 and up by setting it to iOS 8 and up, meaning that I don't have an iPhone 4 storyboard. How do I solve this issue?
It is not possible otherwise to restrict your app on a per device basis. Since your app is iOS 8 and up, you will have to support iPhone 4S's resolution. Since iPhone 4S is getting iOS 9 too, you will have to support it in the near future too.
iPad always presents a view size equal to iPhone 4S or lower when you run iPhone app in iPad. So try to change your app in such a way that your app should work properly with iPhone 4 simulator or device.
You solve the problem by either supporting the iPad properly (have an iPhone + iPad application), or by supplying a storyboard for 3.5 inch - alternatively, using the 4 inch storyboard, using layout constraints properly, and perhaps adjusting some properties.
The obvious change for picking the right storyboard is to change: if (height <= 568) .. else if (height <= 667) ... else ... Your code says that everything that isn't 568 or 667 pixels high is a 6+, which as you can see is nonsense.
You could also just support the iPad and use the 6+ storyboard for the iPad. Again, using layout constraints properly.

How to change XCode Default storyboard Ipad to Iphone?

My OS version is OS X Version 10.9.4.
XCode Version is 6.0.1
Everytime I create a new project ,the storyboard is always for ipad even I choose Device to iphone.The old projects with iphone storyboard work fine.But Everytime I create a new project whatever I choose ,it is always ipad storyboad.Please help me!
You can change it programmatically
NSString *storyName = #"MainStoryboard_iPhone";
if ([[UIDevice currentDevice] userInterfaceIdiom] ==UIUserInterfaceIdiomPad) {
storyName = #"MainStoryboard_iPad";
}
UIStoryboard *story = [UIStoryboard storyboardWithName:storyName bundle:[NSBundle mainBundle]];
or made by default the storyboard on your settings projects. On General, deployment target, main interface, switch between iPhone / iPad
On xCode 7: select the View Controller, click on Attributes Inspector at the top of the Utilities sidebar (left side.) At the top is a size drop down. Use it to select the size you want to view.
Appears this has to be done for each ViewController.

Setting up an universal application in ios

I have created an universal application which runs fine on my ipad . But the image sizing for the iphone isnt perfect . I have tried all the view modes .Can anyone help with this issue .
I have added all the images with all the different resolutions .
Create two different storyboard/xib for iPhone and i Pad.
You have to check condition for iPhone and i Pad.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
//for i Pad.
}
else
{
//for iPhone.
}
Check under project - Deployment Info if your iPhone and iPad refers to the correct Main interfaces (for iPhone you should have youre iPhone storyboard and for iPad your iPad storyboard).
You can find Deployment info here

Change GUI when selecting iOS 6 in Xcode 5

When I am using Xcode 5 and I set the deployment target as 7.0, the application runs perfectly with both 4-inch and 3.5-inch displays.
I have downloaded the iOS 6 SDK already.
When I change the base SDK to iOS 6 and set the deployment target as iOS 6.1 my GUI is affected in a way that changes every image, navigation bar, images and all other controls.
I am not using autolayout and have two .xib files for one UIViewController in each class.
So, how can I get fix this?
Thanks in advance.
When you compile with the iOS 6 SDK , you application is created with the iOS6 images, views, keyboards, etc...
You can't use iOS7 views if you are compiling for iOS6, you need to compile for iOS7, even thought your app is iOS6 compatible (setting the deployment target to iOS6)
Long story short - you can't use iOS 7 GUI in your iOS 6 app. If you want you can just create your custom GUI and use it in your app. But some elements will be different, you better read this guide:
Apple docs
Also if you build you app for different versions of iOS you better use auto layout:
Ray Wenderlich - Auto Layout Tutorial in iOS 7: Part 1
Ray Wenderlich - Auto Layout Tutorial in iOS 6: Part 1
Some issues of transition from iOS 6 to iOS 7:
Status bar and navigation bar issue in IOS7
Use this code:
if([[[UIDevice currentDevice] systemVersion] isEqualToString: #"7.0"])
{
//do stuff
}
else
{
// code here
}
When compiling for iOS 7 you are using iOS 7 specific GUI elements (that differs a lot from iOS 6). Phones that are still on iOS 6 (about 16%) will however see the iOS 6 GUI elements for obvious reasons, even if you compile it for iOS 7.
There is really no way to resolve this, you should simply develop for iOS 7 and let iOS 6 users still have iOS 6 GUI elements.
If your application is working fine in iOS 7 and you need to run it iOS 6 then you need to manage the application using this method:
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending){
//CGRect gridFrame;
if ([[UIScreen mainScreen] bounds].size.height == 568) {
// Do nothing if already managed
}else{
// Do nothing if already managed
}
}else{
//CGRect gridFrame for ios6;
if ([[UIScree`enter code here`n mainScreen] bounds].size.height == 568) {
//Manage frame here
}else{
//Manage frame here
}
}

Universal app popover in iPad version

I am converting an iphone app to the iPad version and I am trying to use a popover in a view in the iPad version.
I am getting an apple mach-o linker id error which disappears when the popover view files are deleted from the project.
Is there any build settings changed/frameworks added when using popovers?
if you want to compile application for both devices you can put
__asm__(".weak_reference _OBJC_CLASS_$_UIPopoverController");
__asm__(".weak_reference _OBJC_CLASS_$_UIPopoverControllerDelegate");
into your Prefix.pch. It will remove errors, but you still won't be able to access those Objects - you will have to add if's to check if you running on iPhone or iPad and present information differently.
something like:
static BOOL isDeviceIPad(){
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
return YES;
}
#endif
return NO;
}

Resources