Callback method for currentViewController

I am having problems with the presentViewController method and its last parameter.

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

I am new to objective-c syntax and cannot find out which object should go to the completion parameter. (also did not find examples that use it)

I want to have a callback method when my submitted View Controller is rejected.

Thanks,

Milos

+4
source share
3 answers

This is the place for block .

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

For termination operations, you can put your code in the viewWillDisappear: or viewDidDisappear: method.

+6
source

An example of creating a completion block:

 [self presentViewController:navigationController animated:YES completion:^(){ //put your code here }]; 

This block does not accept parameters. other blocks can take parameters, and you can define them as follows:

 ^(BOOL bFinished){ //put your code here } 
+17
source

This method will not give you what you want. The completion block is executed when the view controller has completed the presentation, and not when it is fired. You will need to use a different template, such as delegation, to receive a callback when the controller is rejected.

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

See presentViewController: animated: completion:

+10
source

Source: https://habr.com/ru/post/1399206/


All Articles