View boot methods that fail

I load this view:

if(commentSubmissionView == nil){
    commentSubmissionView = [[CommentSubmissionController alloc] initWithNibName:@"CommentSubmissionView" bundle:nil];  
}
[self.view addSubview:commentSubmissionView.view];

viewDidLoad and viewWillAppear in commentSubmissionView do not start. Is there anything else I need to do?

+3
source share
3 answers

The documentation for is viewWillAppear:not entirely clear, but look what it says:

, . , addSubview: , . , ( presentModalViewController: : ). .

viewDidAppear: viewWillAppear: , :

  • ( - )
  • pushViewController: presentModalViewController:animated: , , Apple, .

, , viewWillAppear: viewDidAppear: .

, viewDidLoad . loadView, view , . , ( ).

addSubview: bringSubviewToFront:, addSubview: . , addSubview:

.

+1

addSubview:, bringSubviewToFront: :

if(commentSubmissionView == nil){
    commentSubmissionView = [[CommentSubmissionController alloc] initWithNibName:@"CommentSubmissionView" bundle:nil];  
}
[self.view addSubview:commentSubmissionView.view];
[self.view bringSubviewToFront:commentSubmissionView.view];
+1

viewDidLoadand viewWillAppearcalled in subclasses of the UIViewController, commentSubmissionViewlooks like a subclass of UIView. As Matt noted, you probably want to click / submit a view controller instead of adding a preview.

0
source

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


All Articles