[Solved] Present a viewcontroller in UIView [closed]

To add a view controller to another view controller, you can do the following: Inside the parent view controller class: addChildViewController(someViewController) view.addSubview(someViewController.view) someViewController.didMove(toParentViewController: self) someViewController.view.translatesAutoresizingMaskIntoConstraints = false Then, set the layout constraints to position the view controller: NSLayoutConstraint.activate([ someViewController.view.leadingAnchor .constraint(equalTo: view.leadingAnchor ), someViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), someViewController.view.bottomAnchor .constraint(equalTo: view.bottomAnchor ), someViewController.view.topAnchor .constraint(equalTo: view.topAnchor ) ]) view.layoutIfNeeded() 2 … Read more

[Solved] Sharing info between ViewControllers [duplicate]

U can use segues for transferring data between viewcontrollers. check this link for more details First of all, u need to declare your dateTimeString as a property in your .h file (ViewController.h) Then you can call the segue using [self performSegueWithIdentifier:@”your_segue_identifier_name” sender:self]; Then – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@”your_segue_identifier_name”]) { } } … Read more

[Solved] When I pass data from TableView to child PageViewController, it can go to next child

The problem here is that you are referencing two completely different objects. In viewDidLoad you create ThongTinBNPage2 viewController and then add it to the viewControllers property of the pageViewController. However, the objects stored in VCArr are two totally different viewControllers. Let’s think about it this way: When viewDidLoad is called you create viewController object #1 … Read more

[Solved] How to push or present UIViewcontroller or storyboard from UIView subclass?

You need to implement protocol method for custom UIView class. For example; #import <UIKit/UIKit.h> @protocol YourCustomViewDelegate <NSObject> – (void)buttonTapped; @end @interface YourCustomView : UIView @property (nonatomic, strong) id< YourCustomViewDelegate > delegate; @end And the .m file you can call buttonTapped delegate method. – (void)myCustomClassButtonTapped:(id)sender { [self.delegate buttonTapped]; } For proper work; set your custom view … Read more

[Solved] How to use autoresize on 2 UIViewControllers? [closed]

Well, part of the problem is that this is illegal: [UIViewControllers1.view addSubview:UIViewControllers2.view]; You must never just wantonly add one view controller’s view to another view controller’s view. There is only one way in which that is allowed outside of a built-in parent-child structure that does it for you (UINavigationController, UITabBafController, UIPageViewController), and that is when … Read more