I am having problems using TransitionfromView while transitioning between views in my app.
Setup
This is the basic setup of the View Controller. It has two views in it. A MKMapView and a UITableView. When the toggle button is pressed, it is supposed to alternate views between map and table.
This is my *.h file
@interface BrowseBeaconsViewController : UIViewController <UITableViewDelegate, MKMapViewDelegate, UITableViewDataSource, CLLocationManagerDelegate >
{
__weak IBOutlet UIBarButtonItem *refreshBeacons;
__weak IBOutlet UIBarButtonItem *toggleView;
MKMapView* beaconMapView;
__weak IBOutlet UITableView* beaconTableView;
}
So the tableview comes from the storyboard while mapview is created in the program.
Problem
[UIView transitionFromView:beaconTableView toView:beaconMapView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {}];
When I transition from TableView from MapView the value of the tableview is null(0x0000000). I do understand the behaviour of the transitionfromview is to remove the view from the parent view. But when I try add the tableview as a subview after the transition it doesn't work, since the value is null. So my question is how do I add the tableview after the transition if the view is nulled?
PS: I apologize if this is a simple question, but I am new to iOS programming and did try to look in the forums before posting this question.
From the docs on that method:
"By default, the view in fromView is replaced in the view hierarchy by the view in toView. If both views are already part of your view hierarchy, you can include the UIViewAnimationOptionShowHideTransitionViews option in the options parameter to simply hide or show them."
So, if you want both views to remain, add the beaconMapView to the view hierarchy, and include the UIViewAnimationOptionShowHideTransitionViews option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With