我創建了視圖旋轉的類別,並在控制器視圖以及窗口(用於顯示自定義指標)上添加了視圖。 我的代碼在xCode 5.X以及xCode6-beta6中正常工作到7.X。但是IOS 8測試版不適合。 它似乎像Windows旋轉不工作與ios 8測試版相同像老ios。ios 8添加到窗口的視圖的旋轉問題
您能否請我建議.... 非常感謝。
我的代碼看起來像
- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration {
if(!self.isIpad)
{
[menu.view rotateViewToOrientation:newStatusBarOrientation animated:YES];
if(newStatusBarOrientation==UIInterfaceOrientationPortrait || newStatusBarOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
if (IS_IPHONE_5) {
menu.view.frame= CGRectMake(0, 518, 320, 50);
} else {
menu.view.frame= CGRectMake(0, 430, 320, 50);
}
} else if(newStatusBarOrientation==UIInterfaceOrientationLandscapeLeft) {
if (IS_IPHONE_5) {
menu.view.frame= CGRectMake(270,0,50,568);
} else {
menu.view.frame= CGRectMake(270,0,50,480);
}
} else {
if (IS_IPHONE_5) {
menu.view.frame= CGRectMake(0,0,50,568);
} else {
menu.view.frame= CGRectMake(0,0,50,480);
}
}
[menu reloadMenu];
}
}
//Method of Menu Class for orientation change setup
- (void)rotateViewToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated {
CGPoint center = self.center;
CGRect bounds = self.bounds;
CGAffineTransform transform = CGAffineTransformIdentity;
int intOri=orientation;
switch (intOri) {
case UIInterfaceOrientationPortraitUpsideDown:
transform = CGAffineTransformMakeRotation(M_PI);
break;
case UIInterfaceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(-M_PI_2);
break;
case UIInterfaceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(M_PI_2);
break;
case UIInterfaceOrientationPortrait:
transform = CGAffineTransformMakeRotation(0);
break;
}
if (animated) {
[UIView beginAnimations:nil context:nil];
}
self.transform = transform;
bounds = CGRectApplyAffineTransform(bounds, transform);
self.bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);
self.center = center;
if (animated) {
[UIView commitAnimations];
}
}
粘貼一些代碼,並告訴你如何獲得的問題,有什麼功能不調用,否則任何事情? – Jageen 2014-09-05 11:42:13
一般來說,大多數開發人員不知道如何構建適當的視圖層次結構,這可能是問題的根源 - 您能否發佈一些關於如何構建您的代碼的代碼? – holex 2014-09-05 11:54:31
@Jageen我已經添加了我的代碼,您能否以任何方式給我建議,我應該如何使我的應用程序兼容ios 8。 – 2014-09-05 12:21:26