2013-02-22 2 views
2

Некоторый код, который я использую, использует устаревший метод dismissModalViewControllerAnimated. Документы говорят, что теперь используют dismissViewControllerAnimated:completion:. Я не уверен в части completion:. В моем случае, если завершение должно быть nil или NULL или что?using rejectViewControllerAnimated: завершение:

Оригинальный код выглядит следующим образом.

- (void)didFinishWithCamera 
{ 
    [self dismissModalViewControllerAnimated:YES]; 

    if ([self.capturedImages count] > 0) 
    { 
     if ([self.capturedImages count] == 1) 
     { 
      // we took a single shot 
      [self.imageView setImage:[self.capturedImages objectAtIndex:0]]; 
     } 
     else 
     { 
      // we took multiple shots, use the list of images for animation 
      self.imageView.animationImages = self.capturedImages; 

      if (self.capturedImages.count > 0) 
       // we are done with the image list until next time 
       [self.capturedImages removeAllObjects]; 

      self.imageView.animationDuration = 5.0; // show each captured photo for 5 seconds 
      self.imageView.animationRepeatCount = 0; // animate forever (show all photos) 
      [self.imageView startAnimating]; 
     } 
    } 
} 

ответ

2

Если вы не заботитесь о завершении, а затем обеспечить пустой блок:

[self dismissModalViewControllerAnimated:YES 
           completion:^(void){}]; 
+0

Так что ноль не в порядке? Я подумал, что полное завершение в норме. –

+0

@WarrenP На самом деле, 'nil' выглядит нормально: http://stackoverflow.com/questions/12445190/dismissmodalviewcontrolleranimated-deprecated – trojanfoe

+0

В этом случае предпочтительным было бы не пустое заполнение, а nil всегда и везде лучше. Ох и меньше набирать знаки пунктуации. –

Смежные вопросы