由iphone 4到iphone 5屏幕增大,会导致之前的应用出现两条黑边。我的应用是给黑边加两张图片进行遮盖。操作方法:
1.在appdelegate中判断是否是iphone5 设备。如果是,加两个window,用以存放图片。
if(iphone 5)
{
nsstring *path = [[nsbundle mainbundle]pathforresource:@"zuobian" oftype:@"png"];
uiiamge *image = [uiimage imagewithcontentsoffile:path];//获取图片
uiimageview *view = [[uiimageview alloc]initwithimage:image];
uiwindow *window1 = [[uiwindow alloc]initwithframe:(cgrect){{0,0},{320,44}}];
[window1 addsubview:view];
window1.windowlevel = 3;
[window1 makekeyandvisible];
同理加上window2(rect为{0,524});
}
2.在应用的入口加上通知:
if(iphone 5)
{
[[nsnotificationcenter defaultcenter]addobserver:self selector(changeNum) name:uideviceOrientationIsLandscape(90) object:nil];
}
-(void)changeNum
{
UIInterfaceOrientation orientation = self.interfaceOrientation;
if(orientation == UIInterfaceOrientationLandscapeLeft && [PublicVarible singleInstance].Is_Iphone5 == NO) //publicVarible为一个判断iphone5的单例{
uiwindow *left = [[uiapplication shareapplication].keyWindow];
left.frame = cgrectmake(0,-44,320,568);
}
else if(*********right && *****)
{
**********
right.frame = cgrectmake(0,44,320,568);
}
}