iOS 9 Objective-C Screen Size Issues

ios 9 objective-c screen size issues

case was missing the LaunchScreen.storyboard in General setting under App icons and launch images:

enter image description here

above function is not work check the follow the below steps:

  1. Navigate to project settings
  2. Under "App Icons and Launch Images" click on "Use Asset Catalog"
  3. Select "Migrate" on the popup that appears.

This should fix the issue.

enter image description here

iOS 9 not showing UIPageViewController full screen

When you add the new LauncScreen.storyboard, you are indicating to the OS that you are supporting iPhone6/6+ native resolutions. Check if you are missing autolayout constraints. Refer this article on how to go about it.

[UPDATED]:

Add constraints to Page Content View Controller as shown below:
enter image description here

Add launch screen file:
enter image description here

Select launch screen file in Target>General:
enter image description here

Enjoy the results:

enter image description here

iOS old application screen size

Just add the various launch screens as mentioned in Image.xcassets

Right Click to add a new iOS launch image set
enter image description here

And then add the respective launch images

enter image description here

Black Screen with iOS 9

You had developed your project in Xcode 6.2, So in your project there is no such file LaunchScreen.Storyboard.

Targets -> General -> Launch Screen File -> Choose your -> Main.Storyboard

Now, run the project.

chanange

iOS device real size in inches

There is no API in iOS to get this. Use this and make sure to update when there are new devices: https://github.com/lmirosevic/GBDeviceInfo

I don't think this would be a problem for the AppStore, but maybe don't include the jailbreak pod.

Also, you could just copy the info out of: https://github.com/lmirosevic/GBDeviceInfo/blob/master/GBDeviceInfo/GBDeviceInfo_iOS.m -- it's just a list of info about the device -- nothing crazy

How to adjust today extension width for iOS 9 iPad Notification in landscape mode?

I had the same problem and I resolved it by obtaining my widget extension width with:

self.view.bounds.size.width

Attention, you have to access self.view in viewDidAppear because on viewDidLoad it may be incorrect, as reported here: Getting width of the Notification-Center inside Today-Extension

Actually, as I know, there is no API to know if your widget is on the left or on the right side of the notification center. But, for example, you can determine it by checking the ratio (screensize / widget-size), or you can calculate your layout in a relative manner, based on the width of your widget, as I do and I recommend.

Just for a numeric example, on the iPad mini 1 with iOS 9, the screen size in landscape is 1024*768, the widget width on the left side is 471 points and on the right side is 328 points.

Unable to fit OpenGL ES view to screen with iOS 8/9 SDK

It ended up being that the view containing the OpenGL layer was actually not being framed properly. I'd investigated this possibility before and thought the framing was correct, and I'm still not sure why my app worked before or how it got into this state where the frame wasn't set correctly. But the solution that worked for me was to match the OpenGL view's frame and bounds to its superview in its layoutSubviews() callback.


- (void)layoutSubviews // for UIView containing OpenGL layer
{
[self remakeFramebuffer];

self.bounds = self.superview.bounds;
self.frame = self.superview.frame;
self.center = self.superview.center;
}

Get screen size on iOS 8

Do following

CGRect Rect=[[UIScreen mainScreen] bounds];

So it will preserves the bounds in the rect.
try once.

dealing with different screen sizes in xcode

The main issue is handling the various screen sizes in relation to your image assets and screen object coordinates.

My solution is to write your code as if you are coding for the iPhone 6 plus. Make all your images @3x size and your screen layout coordinates for the iPhone 6 screen size.

With just a bit of code I was able to get an uniform layout for the iPhone 6 plus, 6, 5 and 4 screen sizes. I have included screen shots for each one. The character image is 300x300. The 2 button images are 100x100.

static const float kIphone6PlusScaleFactorX = 1.0;
static const float kIphone6PlusScaleFactorY = 1.0;
static const float kIphone6ScaleFactorX = 0.9;
static const float kIphone6ScaleFactorY = 0.9;
static const float kIphone5ScaleFactorX = 0.772;
static const float kIphone5ScaleFactorY = 0.772;
static const float kIphone4ScaleFactorX = 0.772;
static const float kIphone4ScaleFactorY = 0.652;

#import "GameScene.h"

@implementation GameScene {
float scaleFactorX;
float scaleFactorY;

SKSpriteNode *node0;
SKSpriteNode *node1;
SKSpriteNode *node2;
SKLabelNode *label0;
}

-(void)didMoveToView:(SKView *)view {
self.backgroundColor = [SKColor blackColor];

if(view.frame.size.height == 736) {
NSLog(@"iPhone 6 plus");
scaleFactorX = kIphone6PlusScaleFactorX;
scaleFactorY = kIphone6PlusScaleFactorY;
}
if(view.frame.size.height == 667) {
NSLog(@"iPhone 6");
scaleFactorX = kIphone6ScaleFactorX;
scaleFactorY = kIphone6ScaleFactorY;
}
if(view.frame.size.height == 568) {
NSLog(@"iPhone 5");
scaleFactorX = kIphone5ScaleFactorX;
scaleFactorY = kIphone5ScaleFactorY;
}
if(view.frame.size.height == 480) {
NSLog(@"iPhone 4");
scaleFactorX = kIphone4ScaleFactorX;
scaleFactorY = kIphone4ScaleFactorY;
}

node0 = [SKSpriteNode spriteNodeWithImageNamed:@"Pic"];
node0.position = CGPointMake(self.size.width/2, self.size.height/2);
[node0 setScale:scaleFactorX];
[self addChild:node0];

node1 = [SKSpriteNode spriteNodeWithImageNamed:@"button0"];
node1.position = CGPointMake(100*scaleFactorX, 100*scaleFactorY);
[node1 setScale:scaleFactorX];
[self addChild:node1];

node2 = [SKSpriteNode spriteNodeWithImageNamed:@"button1"];
node2.position = CGPointMake(314*scaleFactorX, 100*scaleFactorY);
[node2 setScale:scaleFactorX];
[self addChild:node2];

label0 = [SKLabelNode labelNodeWithFontNamed:@"HelveticaNeue-Bold"];
label0.text = @"Big Game Menu";
label0.fontSize = 48*scaleFactorX;
label0.fontColor = [SKColor whiteColor];
label0.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
label0.verticalAlignmentMode = SKLabelVerticalAlignmentModeCenter;
label0.position = CGPointMake(207*scaleFactorX,690*scaleFactorY);
[self addChild:label0];
}

iPhone 4

enter image description here

iPhone 5

enter image description here

iPhone 6

enter image description here

iPhone 6 Plus

enter image description here

Notice how even the text label is scaled down correctly not just by font size but also location.

You can use the above logic to also spawn nodes in relation to the screen size.

For your reference, I did use the standard code in my GameViewController because I find it easier to work with a simpler version. This is the code I used to present my SKView:

- (void)viewDidLoad {
[super viewDidLoad];

SKView * skView = (SKView *)self.view;
SKScene *scene = [GameScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];
}


Related Topics



Leave a reply



Submit