2012-09-28 26 views
23

Acabo de actualizar iOS 6 y ejecuto mi código anterior, que se creó en iOS 4.3. Me dan varias advertencias en mi aplicación.dismissmodalviewcontrolleranimated está en desuso primero en desuso en ios 6

que utilizan presentModelViewController: y luego descartarlo, pero me dio aviso

dismissModalViewControllerAnimated is deprecated first deprecated in iOS 6.

¿Por que se muestre una advertencia a ese código? Aquí está el código:

[picker dismissModalViewControllerAnimated:YES]; 

Esta línea se pone amarilla y muestra el error. Por favor, dame una guía para eliminar la advertencia.

+2

leer los documentos UIViewController , ellos te dirán que usar en su lugar – wattson12

+0

dar el código de donde creas 'selector' ViewController y cómo :) –

Respuesta

2

Puede utilizar dismissViewControllerAnimated:completion, a partir de los documentos iOS Developer

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

gracias por la guía, ... funciona bien. ¿Puedo hacerte una pregunta? por qué su uso "finalización: (void (^) (void)) finalización", – Piyush

+0

es "un bloque llamado después de que el controlador de vista ha sido descartado" – ChristianD

59

Ahora en iOS 6, se pueden utilizar

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

En lugar de

[[Picker parentViewControl] dismissModalViewControllerAnimated:YES]; 

y

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

En lugar de

[self presentModalViewController:picker animated:YES]; 
4

Sólo debe obtener la advertencia desaprobación si su destino de distribución se establece en iOS 6. Así que me gustaría comprobar el destino de implementación, lo que probablemente se establece en el valor por defecto de Xcode. Una vez que cambie esto a 4.3, las advertencias de desaprobación deberían desaparecer.

2

puedo cambiar mi código

[self dismissModalViewControllerAnimated:YES]; 

a

[self dismissViewControllerAnimated:YES]; 

y recibir de error: No se @interface visibles para 'KLPARewardController' declara el selector 'dismissViewControllerAnimated:'

Cuestiones relacionadas