2011-09-30 40 views

Trả lời

16

Không có hằng số nào chứa giá trị này. Tuy nhiên, bằng cách sử dụng UINavigationControllerDelegate phương pháp sau đây:

- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
{ 
    startTime = [[NSDate date] retain]; 
} 

- (void) navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
{ 
    NSLog(@"Duration %f", [[NSDate date] timeIntervalSinceDate: startTime]); 
} 

... Tôi có thể thấy rằng thời gian là khoảng 0,35 giây

Điều thú vị là, các bộ phận khác nhau của các quan điểm lấy thời điểm khác nhau để chuyển vào vị trí. Xem bài đăng blog tuyệt vời này để biết thêm chi tiết:

http://www.iclarified.com/12396/a-closer-look-at-iphone-transition-animations

+0

Bài đăng trên blog tuyệt vời! Cảm ơn các liên kết. – morais

+29

Trên iOS 8, thời lượng hoạt ảnh xuất hiện là '0,2' giây. (Hiện tại có một hằng số bạn có thể tham khảo: 'UINavigationControllerHideShowBarDuration'.) – zekel

+1

Nhận xét này phải là câu trả lời, nó giúp tôi rất nhiều lần – fpg1503

14

Trong iOS 7 và sau đó bạn có thể có giá trị chính xác bằng cách thiết lập UINavigationController đại biểu và sử dụng phương pháp này:

- (void)navigationController:(UINavigationController *)navigationController 
     willShowViewController:(UIViewController *)viewController 
        animated:(BOOL)animated { 
    NSTimeInterval duration = [viewController.transitionCoordinator transitionDuration]; 
} 

Đây là tương lai phương pháp chứng minh nếu thời gian phỉ báng sẽ thay đổi. Hiện tại, giá trị của nó là 0,35 giây.

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