Xcode 4 UIButton segue push to Table View Controller

后端 未结 2 739
执念已碎
执念已碎 2021-01-07 03:54

Right now I have a UIButton setup in my storyboard that pushes to a Table View Controller. This is working as expected. What I am trying to do is have the

2条回答
  •  离开以前
    2021-01-07 04:38

    Drag your button connection to the new view and select custom Segue instead of Push or Modal.

    enter image description here

    Change the new custom Segue's class to "mySegueClass1" or what ever you'd like to call it.

    enter image description here

    Create a new Objective-C class with the same name as you just assigned to the custom segue.

    enter image description here Then inside your mySegueClass1.m file add the following code, and add what ever additional actions you want to -(void)perform

    -(void)perform{
        UIViewController *dst = [self destinationViewController];
        UIViewController *src = [self sourceViewController];
        [dst viewWillAppear:NO];
        [dst viewDidAppear:NO];
    
    
        [src.view addSubview:dst.view];
    
        CGRect original = dst.view.frame;
    
        dst.view.frame = CGRectMake(dst.view.frame.origin.x, 0-dst.view.frame.size.height, dst.view.frame.size.width, dst.view.frame.size.height);
    
        [UIView beginAnimations:nil context:nil];
        dst.view.frame = CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width);
        [UIView commitAnimations];
    
        [self performSelector:@selector(animationDone:) withObject:dst afterDelay:0.2f];
    }
    - (void)animationDone:(id)vc{
        UIViewController *dst = (UIViewController*)vc;
        UINavigationController *nav = [[self sourceViewController] navigationController];
        [nav popViewControllerAnimated:NO];
        [nav pushViewController:dst animated:NO];
    }
    

提交回复
热议问题