使用图片资源全局控制图片是否正确,看是否有警告。
为了将来更好地使用最后一个 Xcode 故事板屏幕:
要将您的应用置于通用模式:
添加情节提要或在自动布局模式下使用情节提要。
要使用多个故事板,您可以在 application didFinishLaunchingWithOptions 内的 AppDelegate 中使用它:
#pragma mark - Universal storyboard.
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
UIStoryboard *storyBoard;
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width *scale, result.height *scale);
if(result.height <= 960){
storyBoard = [UIStoryboard storyboardWithName:@"iPhone4" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
}
}
您可以添加所有分辨率的 iPhone 4s / 5 (s/c) 6 和 6 Plus
在您的<AppName>-Prefix.pch 中定义所有分辨率,如下所示:
#define IsIphone5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IsIphone4 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )480 ) < DBL_EPSILON )
然后在您的项目中调用该函数,例如 iPhone 4/5 和 iPad 的一个滚动视图:
- (void)spiegaScroll{
if (IsIphone5){
CGRect scrollFrame;
scrollFrame.origin = myScroll.frame.origin;
scrollFrame.size = CGSizeMake(320, 568);
spiega.frame = scrollFrame;
[spiega setContentSize:CGSizeMake(320, 1100)];
myScroll.scrollEnabled = YES;
myScroll.pagingEnabled = NO;
myScroll.clipsToBounds = NO;
} else if (IsIphone4) {
CGRect scrollFrame;
scrollFrame.origin = myScroll.frame.origin;
scrollFrame.size = CGSizeMake(320, 480);
spiega.frame = scrollFrame;
[spiega setContentSize:CGSizeMake(320, 1100)];
myScroll.scrollEnabled = YES;
myScroll.pagingEnabled = NO;
myScroll.clipsToBounds = NO;
} else {
//the rest is iPad in this case
CGRect scrollFrame;
scrollFrame.origin = myScroll.frame.origin;
scrollFrame.size = CGSizeMake(768, 1024);
spiega.frame = scrollFrame;
[spiega setContentSize:CGSizeMake(768, 2094)];
myScroll.scrollEnabled = YES;
myScroll.pagingEnabled = NO;
myScroll.clipsToBounds = NO;
}
}
希望这对您现在或将来的应用有所帮助;)