Developing fullscreen 4inch app in xcode [duplicate]

天大地大妈咪最大 提交于 2019-11-28 21:40:20
Hannes Sverrisson

Some users have reported that it was fixed after adding the startup image Default-568h@2x.png (see below). For updating to iPhone5 I did the following:

Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate methods. Thus, I added these new methods (and kept the old for iOS 5 compatibility):

-(BOOL)shouldAutorotate {
  return YES;
}

- (NSUInteger)supportedInterfaceOrientations{
  return UIInterfaceOrientationMaskAllButUpsideDown;    
}
  • Then I fixed the autolayout for views that needed it.
  • Copied images from the simulator for startup view and views for the iTunes store into PhotoShop and exported them as png files.
  • The name of the default image is: Default-568h@2x.png the size is 640 x 1136 and the screen size 320 x 568.
  • I have dropped backward compatibility for iOS 4. The reason is that this new Xcode does not support armv6 code any more. Thus, all devices that I am able to support now (running armv7) can be upgraded to iOS 5.

That was all but just remember to test the autorotation in iOS 5 and iOS 6 because of the changes in rotation.

Before iPhone 5 release, I just use

#define kViewHeight 460.f // or 480.f if you don't have a status bar
#define kViewWidth  320.f

But now, I would like to use

#define kViewHeight CGRectGetHeight([UIScreen mainScreen].applicationFrame)
#define kViewWidth  CGRectGetWidth([UIScreen mainScreen].applicationFrame)

instead.

But I'm not sure whether it is a good solution. As you see, you would dispatch CGRectGetHeight([UIScreen mainScreen].applicationFrame) every where you use kViewHeight. I've tried to use

extern float kViewHeight; // in .h
float kViewHeight = CGRectGetHeight([UIScreen mainScreen].applicationFrame) // in .m

but failed with a compile error.

Though it works well, I think there must be a better workaround. ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!