2012-09-28 17 views
23

Właśnie zaktualizowałem iOS 6 i uruchom mój stary kod, który jest tworzony w iOS 4.3. Dają mi liczbę ostrzeżeń w mojej aplikacji.dismissmodalviewcontrolleranimated jest przestarzałe jako pierwsze wycofane w ios 6

użyłem presentModelViewController: a potem odrzucić go, ale on dał mi ostrzeżenie

dismissModalViewControllerAnimated is deprecated first deprecated in iOS 6.

Dlaczego oni Pokaż ostrzeżenie do tego kodu? Oto kod:

[picker dismissModalViewControllerAnimated:YES]; 

Ta linia jest żółta i pokazuje błąd. Proszę podać mi wytyczną, aby usunąć ostrzeżenie.

+2

przeczytać docs UIViewController , powiedzą ci, co używać zamiast tego: – wattson12

+0

podaj kod miejsca, w którym utworzysz 'picker' ViewController i jak :) –

Odpowiedz

2

Można użyć dismissViewControllerAnimated:completion, z iOS Developer docs

dismissViewControllerAnimated:completion:

Dismisses the view controller that was presented by the receiver. - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion Parameters

flag

Pass YES to animate the transition. completion 

A block called after the view controller has been dismissed. 

Discussion

The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.

If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

If you want to retain a reference to the receiver’s presented view controller, get the value in the presentedViewController property before calling this method.

The completion handler is called after the viewDidDisappear: method is called on the presented view controller. Availability

Available in iOS 5.0 and later. 
+0

dzięki za wskazówki, .. działa dobrze. Czy mogę Ci zadać jedno pytanie? dlaczego ich użycie "ukończenie: (void (^) (void)) complete", – Piyush

+0

jest "blokiem wywoływanym po tym, jak kontroler widoku został zwolniony" – ChristianD

59

Teraz w iOS 6 można użyć

[[Picker presentingViewController] dismissViewControllerAnimated:YES completion:nil]; 

zamiast

[[Picker parentViewControl] dismissModalViewControllerAnimated:YES]; 

i

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

Zamiast

[self presentModalViewController:picker animated:YES]; 
4

Powinieneś dostać tylko ostrzeżenie Deprecation jeśli celem wdrożenia jest ustawiony na iOS 6. Więc chciałbym sprawdzić swój cel wdrażania, która jest prawdopodobnie ustawiony domyślnie Xcode. Po zmianie tego na 4.3, ostrzeżenia o wycofaniu powinny zniknąć.

2

zmienić mój kod

[self dismissModalViewControllerAnimated:YES]; 

do

[self dismissViewControllerAnimated:YES]; 

i odbieranie błąd: Brak widocznych @interface dla 'KLPARewardController' deklaruje selektor 'dismissViewControllerAnimated:'

Powiązane problemy