2013-06-11 40 views
11

Tôi nhận được một cảnh báo trong XCode:presentModalViewController: hoạt hình bị phản

'presentModalViewController:animated:' is deprecated: first deprecated in iOS 6.0 

trên dòng mã này:

[self presentModalViewController:initialSettingsVC animated:YES]; 

Tôi cố gắng để thay thế nó như đề xuất trong documentation với:

[self presentModalViewController:initialSettingsVC animated:YES completion:nil]; 

Tôi hiện đã gặp lỗi trong XCode:

Không @ interface có thể nhìn thấy cho 'ViewController' tuyên bố chọn 'presentModalViewController: hoạt hình: hoàn thành:'

Bất kỳ ý tưởng?

+1

Bạn đã sai chính tả phương pháp. Đó là 'presentViewController: animated: completion'. Loại bỏ 'Phương thức'. – bbarnhart

+0

@bbarnhart Bạn nói đúng. Đây là giải pháp. – poiuytrez

Trả lời

4

Bạn muốn sử dụng như sau

- (void)presentViewController:(UIViewController *)viewControllerToPresent 
         animated: (BOOL)flag completion:(void (^)(void))completion; 

settting UIModalPresentationStyleUIModalTransitionStyle cho viewController để có được những hình ảnh động modal/trình bày bạn đang tìm kiếm

12

Sử dụng sau ....... .

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){ 
    [self presentViewController:test animated:YES completion:nil]; 
} else { 
    [self presentModalViewController:test animated:YES]; 
} 

tôi tìm thấy Here

5

Thay

[self presentModalViewController:initialSettingsVC animated:YES completion:nil]; 

Để

[self presentViewController:reader animated:YES completion:nil]; 
+1

Như của ios 10, điều này sẽ không làm một bài thuyết trình phương thức. –

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