Bonjour,iOS項目在iPhone上工作,但不在模擬器中
我的iOS項目支持風景,並在我的iPhone 4s 7.1.2上完美運行,但在模擬器中沒有。
這裏是一些截圖:
兩個截圖已經採取了橫向模式和模擬器似乎並沒有調整板正確
這裏我使用的代碼改變方向。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
[UIView animateWithDuration:duration animations:^{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
int width = [[UIScreen mainScreen] bounds].size.width - [[UIApplication sharedApplication] statusBarFrame].size.width - 10;
int height = width;
int x = 5;
int y = ([[UIScreen mainScreen] bounds].size.width/2) - (width/2);
[board setFrame:CGRectMake(x, y, width, height)];
}];
}
else {
[UIView animateWithDuration:duration animations:^{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[board setFrame:CGRectMake(0, [UIApplication sharedApplication].statusBarFrame.size.height, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.width)];
}];
}
}
感謝您的幫助:)
你有沒有設置斷點,看看有什麼價值你得到? – AdamPro13
據我所知,willAnimateRotationToInterfaceOrientation不能在模擬器上工作,因爲它是由iPhone設備的加速度傳感器觸發的。顯然,模擬器沒有。 – skyline75489
你可以在iOS模擬器 - >硬件 - >向左旋轉/向右旋轉 – user3650409