2010-12-30 48 views
7

mã bên dưới triển khai chuyển đổi giữa hai chế độ xem trong hoạt ảnh khối lập phương.chuyển đổi chế độ xem của hai chế độ xem trong hình động khối lập phương

UIViewController* viewCtrl = [[UIViewController alloc] init:book]; 

CATransition *transition = [CATransition animation]; 
transition.duration = 1; 
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
transition.type = @"cube"; 
transition.subtype = kCATransitionFromLeft; 
transition.delegate = self; 
[self.navigationController.view.layer addAnimation:transition forKey:nil]; 
self.navigationController.navigationBarHidden = NO; 
[self.navigationController pushViewController:viewCtrl animated:YES];  

[viewCtrl release]; 

nhưng nếu chế độ xem không thuộc về self.navigationController, làm thế nào để làm chuyển đổi trong hoạt hình khối lập phương giữa hai bộ điều khiển xem, và sau đó làm thế nào để mở rộng tầm nhìn quan điểm điều chỉnh dòng điện trong cùng một lúc? cảm ơn rất nhiều

Trả lời

8

này đã làm việc cho tôi:

-(IBAction)animate:(id)sender { 
    NSLog(@"animate"); 

    CATransition *transition = [CATransition animation]; 
    transition.delegate = self; 
    transition.duration = 0.8; 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
    NSString *types[4] = {@"cube", @"rippleEffect", @"cube", @"alignedCube"}; 
    NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromRight}; 

    transition.type = types[0]; 
    transition.subtype = subtypes[1]; 

    [self.view.layer addAnimation:transition forKey:nil]; 

    SecondView *_secondViewController = [[SecondView alloc]initWithNibName:@"secondView" bundle:nil]; 
    self.secondViewController = _secondViewController; 
    _secondViewController = nil; 

    [[[self view] layer] addAnimation: transition forKey: nil]; 
    [[self view] addSubview: [self.secondViewController view]]; 
} 

-(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag{ 
    [self.view release]; 
} 
+5

Lưu ý rằng tất cả các 'loại' trên không có giấy tờ và nếu bạn đang sử dụng chúng phát hiện ứng dụng của bạn có thể bị kéo. Ngoài ra, họ có thể biến mất (hoặc được đổi tên) trong bất kỳ phiên bản nào. –

Các vấn đề liên quan