2012-09-24 24 views
6

Trong iOS 5 nó chạy một cách chính xác:Lỗi để trình bày quan điểm điều khiển trung vào iPad iOS 6

PinRequiredViewController *pinView = [[PinRequiredViewController alloc]initWithNibName:@"PinRequiredView" bundle:nil]; 

      UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pinView]; 

      // show the navigation controller modally 
      navController.modalPresentationStyle = UIModalPresentationFormSheet; 
      navController.modalInPopover = NO; 
      navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

      [self presentViewController:navController animated:YES completion:nil]; 

      navController.view.superview.frame = CGRectMake(0, 0, 250, 250); 

      navController.view.superview.center = self.view.window.center; 

Nhưng không phải làm việc tốt trong iOS6, quan điểm không ở lại tập trung ở màn hình, cả hai bức chân dung và phong cảnh. Bất kỳ giải pháp nào?

Cảm ơn !! :)

+0

Tôi có cùng một vấn đề và không thể giải quyết được. Được sử dụng để hoạt động tốt trước iOS 6. –

+0

@ Javi_576 Chính xác vấn đề ở đây là gì? Các câu hỏi nói "không hoạt động" không phải là mô tả kỹ lưỡng về vấn đề này. Bạn đang nói rằng nó không có mặt? –

+1

Không, chế độ xem được căn giữa trong iOS5 với mã này, nhưng không có trong iOS6. –

Trả lời

8

Tôi nghĩ rằng nó sẽ làm việc nếu bạn loại bỏ phong cách UIModalTransitionStyleFlipHorizontal chuyển và sử dụng một trong các kiểu chuyển đổi khác để thay thế.

Dường như đó là lỗi với UIModalTransitionStyleFlipHorizontal.

+0

Cảm ơn người đàn ông! Đó là một lỗi vì tôi đã sử dụng một 'UIModalTransitionStyle' khác và chạy OK! :) –

1

Vấn đề là bạn có thể đặt khung của superview thành bất kỳ thứ gì bạn muốn nhưng nguồn gốc sẽ không bị thay đổi. Đó là lý do tại sao nó không tập trung.

Có vẻ như Apple hạn chế này vào mục đích trong iOS6

+0

Cảm ơn bạn đã trả lời! Tôi cho rằng đó là ... –

3

Sử dụng hoàn thành: trong presentViewController của bạn:

[self presentViewController:navController animated:YES completion:^{ 
     navController.view.superview.bounds = CGRectMake(0, 0, 250, 250);}]; 

Điều này sẽ làm cho nó hoạt động với UIModalTransitionStyleFlipHorizontal.

+2

Đây là một bước đi đúng hướng, nhưng hoạt ảnh phương thức là kích thước không chính xác cho đến khi hoạt ảnh hoàn tất. Kết quả cuối cùng là chói tai. –

+2

Trên iOS6 navCon.view.superview.bounds = CGRectMake (0, 0, kPopupsWidth, kPopupsHeight) sau presentViewController: animated: completion: được sử dụng để làm việc, nhưng không còn trên iOS7 (Beta 5). Xem được thay đổi kích cỡ, nhưng không tập trung ... Khi hoàn thành công việc, nhưng một hoạt hình xấu xí như địa ngục! –

0

Chỉ cần làm điều đó trong chế độ xemDidAppear thay vì viewDidLoad. Và bạn đã được sắp xếp!

1

Trong sự hiểu biết của tôi với UIModalTransitionStyleFlipHorizontal, cách duy nhất là hiển thị lần đầu tiên mà không có hoạt ảnh, đặt điểm trung tâm, sau đó bỏ qua dòng tiếp theo và hiển thị lại bằng hoạt ảnh: yes. Như dưới đây .....

[self presentViewController:navController animated:NO completion:nil]; 

CGPoint centerPoint = CGPointMake([[UIScreen mainScreen] bounds].size.width/2, [[UIScreen mainScreen] bounds].size.height/2); 
navController.view.superview.center = centerPoint; 
[navController dismissModalViewControllerAnimated:NO]; 

navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentViewController:navController animated:YES completion:nil]; 
1

tôi đã thành công với những điều sau:

aboutViewController.modalPresentationStyle = UIModalPresentationFormSheet; 
aboutViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 

CGRect aboutSheetFrame = aboutViewController.view.frame; 
[self presentViewController:aboutViewController animated:YES completion:^{ 
     aboutViewController.view.superview.bounds = aboutSheetFrame; 
     }]; 
aboutViewController.view.superview.bounds = aboutSheetFrame; 

Sử dụng UIModalTransitionStyleFlipHorizontal chuyển tiếp vẫn là buggy trên ios 6.1 beta 2. aboutSheetFrame là để tránh kích thước hardcoding.

0

Đối với iOS 7 thử điều này:

[self.navigationController presentViewController:navigationController animated:YES completion:^{ 
    //Make the modal bigger than normal 
    navigationController.view.superview.bounds = CGRectMake(0, 0, 700, 650); 
}]; 

Hoạt ảnh sẽ trông xấu xí vì vậy tôi sẽ khuyên bạn nên thêm một hình ảnh động để cải thiện nó:

[self.navigationController presentViewController:navigationController animated:YES completion:^{ 
    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ 
     //Make the modal bigger than normal 
     navigationController.view.superview.bounds = CGRectMake(0, 0, 700, 650); 
    } completion:^(BOOL finished) { 
    }]; 
}]; 

Cũng nên nhớ rằng bạn sẽ cần phải thiết lập các khung của khung nhìn navigationControllers trong viewDidAppear cho nội dung có kích thước chính xác.

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