버튼을 클릭하여 이러한 뷰를 화면에서 서로 밀어 내도록했습니다.오리엔테이션 변경 후 뷰가 잘못 슬라이드 됨
그러나 장치를 가로 방향으로 변경하면보기가 화면 밖으로 반쯤 만 튀어 나와 붙습니다. 왜 이런 일이 일어 났는지는 이해하지만 어떻게 고쳐야하는지 이해합니다.
버튼을 세로 및 세로 모드로 모두 클릭하면 화면이 완전히 슬라이드되지 않게 할 수 있습니까? 그게 내가해야 할 일이다.
내 코드는이
.H 파일
@interface AnimationBlocksViewController : UIViewController{
IBOutlet UIView *theview;
IBOutlet UIView *theview2;
BOOL isAnimated;
BOOL switchback;
}
-(IBAction)animate:(id)sender;
-(IBAction)change:(id)sender;
@end
하는 .m 파일 I 비슷한 질문이나 튜토리얼에 대한 피드백, 샘플, 또는 링크 감사
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
isAnimated = NO;
}
-(IBAction)animate:(id)sender;{
if (isAnimated) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.5];
[theview setFrame:CGRectMake(0, 0, 320, 460)];
[theview2 setFrame:CGRectMake(320, 0, 320, 460)];
[UIView commitAnimations];
isAnimated=YES;
}
else{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.5];
[theview setFrame:CGRectMake(-320, 0, 320, 460)];
[theview2 setFrame:CGRectMake(0, 0, 320, 460)];
[UIView commitAnimations];
isAnimated=NO;
}
}
-(IBAction)change:(id)sender;{
if (switchback) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.5];
[theview2 setFrame:CGRectMake(0, 0, 320, 460)];
[UIView commitAnimations];
switchback=NO;
}
else{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.5];
[theview2 setFrame:CGRectMake(320, 0, 320, 460)];
[theview setFrame:CGRectMake(0, 0, 320, 460)];
[UIView commitAnimations];
switchback=NO;
}
}
처럼 읽습니다.
고맙습니다.
이상적인 해결책으로 "self.view.bounds.size.width"를 참조하십시오. 화면에서 왼쪽으로 이동하려면이 값을 음수로 할 수있는 방법이 있습니까? –
아 잠깐, 그냥 사용 - = 이것은 완벽하게 당신에게 정말 고마워했습니다 !!! –