1
我正在使用UIView動畫,其中第二個視圖從底部出現並出現在視圖的中心。但它不能在橫向模式下工作,儘管我的應用程序支持橫向模式,而且我實現了「willAnimateRotationToInterfaceOrientation:toInterfaceOrientation」方法。這裏是我的代碼:UIView動畫不適用於橫向模式
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.view.backgroundColor = [UIColor blackColor];
imageView= [[UIImageView alloc] initWithFrame:CGRectMake(0, 499, 320, 0)];
imageView.image = [UIImage imageNamed:@"trans.png"];
[imageView setClipsToBounds:YES];
[imageView setContentMode:UIViewContentModeBottom];
[self.view addSubview:imageView];
[UIView animateWithDuration:1.0f
delay:0.5f
options:UIViewAnimationOptionCurveEaseOut
animations:^(void) {
imageView.frame = CGRectMake(0, 92, 320, 320);
}
completion:NULL];
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
CGRect screen = [[UIScreen mainScreen] bounds];
float pos_y, pos_x;
pos_y = UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]) ? screen.size.width/2 : screen.size.height/2;
pos_x = UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]) ? screen.size.height/2 : screen.size.width/2;
imageView.center = CGPointMake(pos_x, pos_y);
}
我猜I'm設置錯了地方第二種觀點的框架...