I'm trying to write my own, custom UIStoryboardSegue
in which a UIView
'slides' from the sourceViewController
to the destinationViewController
. Currently, I have the code below:
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UINavigationController *navigationController = [[self sourceViewController] navigationController];
RestaurantViewController *destinationViewController = self.destinationViewController;
destinationViewController.colors.frame = CGRectMake(0, 0, 10, 10);
[sourceViewController.view addSubview:destinationViewController.tables];
[UIView animateWithDuration:10.0
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
destinationViewController.tables.frame = CGRectMake(100, 100, 100, 100);
}
completion:^(BOOL finished){
[destinationViewController.tables removeFromSuperview]; // remove from temp super view
[navigationController pushViewController:destinationViewController animated:NO]; // present VC
}];
}
As a test, I'm just playing around with the frame of the tables view. I also set the duration to a whopping 10 seconds, so that I could see everything. However, the destinationViewController
is just snapping into place, completely ignoring all the code I wrote. What am I doing wrong here?
Hello I am trying with your code to make this work, but I found that your main problem is that your destinationViewController.tables
is nil that is why nothing seems to work.
You need to secure that your destinationViewController.tables
is not nil, you can do this in your RestaurantViewController
class with something like this
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
self.tables = [[UIView alloc]initWithCoder:coder];
}
return self;
}
Hope this help you. Sorry for my english