iOS6之前使用的旋轉函式已經無法使用了,而是使用-(NSUInteger)supportedInterfaceOrientations與-(BOOL)shouldAutorotate來配合旋轉。
但是如果在旋轉後要呼叫自定程序去處理自定界面呢?
首先,這是我的自定義程式:
-(void)turnInterface:(NSInteger)orit{
NSLog(@"Turn! %d",orit);
}
原本就程式碼寫的旋轉呼叫:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
[self turnInterface:(NSInteger)interfaceOrientation];
return YES;
}
現在則是需要使用didRotateFromInterfaceOrientation:來呼叫程序:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
NSInteger interfaceOrientation = 0;
if (fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
interfaceOrientation = UIInterfaceOrientationLandscapeLeft;
}else{
interfaceOrientation = UIInterfaceOrientationPortrait;
}
[self turnInterface:interfaceOrientation];
}
沒有留言:
張貼留言
歡迎大家留言提問,我會答的都會盡力回答!
如果太久沒出現回應就是我又忘記回來看留言了TAT