2013-04-03 39 views
7

Tôi đang thiết lập self.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; trong Đại biểu ứng dụng của mình để tôi có thể trình bày bộ điều khiển xem và có chế độ xem trong suốt (xem SO question) này.Trình bày bộ điều khiển xem với độ trong suốt và hoạt ảnh

Điều này làm việc tuyệt vời, chỉ nhận xét là tôi không thể hoạt ảnh khi bộ điều khiển xem được trình bày. Có ai từng nhận làm công việc này chưa? Nếu không, tôi có những lựa chọn nào khác?

Trình điều khiển chế độ xem tôi đang trình bày là một "hướng dẫn" bao gồm UIScrollViewUIPageControl được cho là "di chuột" trên giao diện để bạn có thể thấy nền hơi ở mép.

Trả lời

9

tôi đã kết thúc làm điều này:

AppDelegate *appDelegate = [AppDelegate sharedAppDelegate]; 

// Set the root VC modal presentation style 
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; 

WalkthroughViewController *walkthroughVC = [[WalkthroughViewController alloc] initWithNibName:nil bundle:nil]; 

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

// Manually animate the view 
walkthroughVC.view.alpha = 0; 
[UIView animateWithDuration:0.5 animations:^{ 
     walkthroughVC.view.alpha = 1; 
}]; 

// Reset root VC modal presentation style 
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen; 
+0

Điều này cũng hữu ích cho tôi khi tôi gọi lại từ AppDelegate (ví dụ như gọi lại xác thực Twitter) và trình bày bộ điều khiển xem trong suốt. – morph85

0

Bạn có thể sử dụng chế độ xem ngăn chặn tồn tại trong bộ điều khiển chế độ xem cơ sở. Thay vì trình bày một phương thức, animate vị trí của khung nhìn ngăn chặn lên để mô phỏng một bài thuyết trình phương thức.

Ví dụ ...

TransparentViewController *viewController = [[TransparentViewController alloc] init]; 
viewController.view.frame = CGRectMake(0, 480, 320, 480); 
self.containmnetView = viewController.view; 

Để trình bày làm điều này:

[UIView animateWithDuration:0.5f animations:^{ 
    self.containmentView.frame = CGRectMake(0, 0, 320, 480); 
}]; 

Tôi hy vọng điều này sẽ giúp.

+0

Hmm bạn đã thấy thread Tôi đã đề cập đến? –

+0

Ah Tôi hiểu ngay bây giờ, đã chỉnh sửa câu trả lời của tôi. Hi vọng điêu nay co ich. –