-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
if(toInterfaceOrientation==UIInterfaceOrientationPortrait ||toInterfaceOrientation== UIInterfaceOrientationLandscapeLeft|| toInterfaceOrientation==UIInterfaceOrientationLandscapeRight ||toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown){
return YES;
} else return NO;
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
self.string=text1.text;
self.string1=text2.text;
if(toInterfaceOrientation ==UIInterfaceOrientationPortrait)
{
self.view=self.portrait;
self.view.transform=CGAffineTransformIdentity;
self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(0));
self.view.bounds=CGRectMake(0.0, 0, 320, 460);
text1.text=[[NSString alloc]initWithString:string1];
}
if(toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown){
self.view=self.portrait;
self.view.transform=CGAffineTransformIdentity;
self.view.transform=CGAffineTransformMakeRotation(180);
self.view.bounds=CGRectMake(0, 0, 320, 460);
text1.text=[[NSString alloc]initWithString:string1];
}
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view =self.landscape;
self.view.transform=CGAffineTransformIdentity;
self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(-90));
self.view.bounds=CGRectMake(0, 0, 480, 300);
text2.text=[[NSString alloc]initWithString:string];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view=self.landscape;
self.view.transform=CGAffineTransformIdentity;
self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(90));
self.view.bounds=CGRectMake(0, 0, 480, 300);
self.text2.text=[[NSString alloc]initWithString:string];
}
} textfield应自动调整所有方向。
选择倒置复选框方向,同时从横向旋转到倒置 将animate方法称为如何解决