當我改變方向我的textview調整不當,界限跳轉到右邊或左邊或下來或上...這是我的代碼,幫助我請....我如何調整我的fullText UIView ..謝謝如何在改變方向時正確調整UIView大小?
- (void)viewDidLoad
{ frameHor=CGRectMake(0,10,275,306);
frameVer=CGRectMake(0, 51, 320, 351);
..
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
//self.view = portraitView;
[self changeTheViewToPortrait:YES andDuration:duration];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
//self.view = landscapeView;
[self changeTheViewToPortrait:NO andDuration:duration];
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
- (void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
if(portrait){
self.titleLabel.hidden=NO;
self.backButton.hidden=NO;
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"det.png"]]];
self.fullText.frame=CGRectMake(frameVer.origin.x, frameVer.origin.y, frameVer.size.width, frameVer.size.height);
}
else{
self.titleLabel.hidden=YES;
self.backButton.hidden=YES;
self.fullText.frame=CGRectMake(frameHor.origin.x, frameHor.origin.y, frameHor.size.width, frameHor.size.height);
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"T_iphoneauto.png"]]];
}
[UIView commitAnimations];
}
是的,謝謝,我明白autoresizingMask技巧,但是當在景觀我隱藏了一些意見和應取消的TextView起來......如果我沒有找到更好的東西,我將停在AutoResizingMask –
當您有其他視圖模式時,您可以更改它的中心屬性或更改框架。 – Nekto