Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8082803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:14:28+00:00 2026-06-05T17:14:28+00:00

I’m doing some custom animations to change views in a single method. I already

  • 0

I’m doing some custom animations to change views in a single method. I already removed "fromView" from superView using [UIView setAnimationDidStopSelector:@selector(removeFromSuperview)], but I also want to enable user interaction after the end of the animation.

Here’s my code:

-(void) switchFrom:(UIViewController*) fromViewController To:(UIViewController*) toViewController usingAnimation:(int) animation{
    UIView *fromView = fromViewController.view;
    UIView *toView = toViewController.view;
    /*************** SET ALL DEFAULT TRANSITION SETTINGS ***************/
    // Get the current view frame, width and height
    CGRect pageFrame = fromView.frame;
    CGFloat pageWidth = pageFrame.size.width;
    
    // Create the animation
    [UIView beginAnimations:nil context:nil];
    
    // Create the delegate, so the "fromView" is removed after the transition
    [UIView setAnimationDelegate: fromView];
    [UIView setAnimationDidStopSelector:@selector(removeFromSuperview)];
    
    // Set the transition duration
    [UIView setAnimationDuration: 0.4];

    /*************** IT DOESN'T WORK AT ALL ***************/
    [toView setUserInteractionEnabled:NO];
    [UIView setAnimationDelegate: toView];
    [UIView setAnimationDidStopSelector:@selector(setUserInteractionEnabled:)];
    [toView setUserInteractionEnabled:YES];

    // Add the "toView" as subview of "fromView" superview
    [fromView.superview addSubview:toView];
    switch (animation) {
        case AnimationPushFromRigh:{
            // Position the "toView" to the right corner of the page            
            toView.frame = CGRectOffset(pageFrame, pageWidth,0);
            
            // Animate the "fromView" to the left corner of the page
            fromView.frame = CGRectOffset(pageFrame, -pageWidth,0);
            
            // Animate the "toView" to the center of the page
            toView.frame = pageFrame;
            
            // Animate the "fromView" alpha
            fromView.alpha = 0;
            
            // Set and animate the "toView" alpha
            toView.alpha = 0;
            toView.alpha = 1;

            // Commit the animation
            [UIView commitAnimations];
        }
        .
        .
        .

Any idea how can I call this two methods in setAnimationDidStopSelector and actually make them work together?

EDIT 1

Tried @safecase code like this, replacing this commented block:

/*************** IT DOESN'T WORK AT ALL ***************
[toView setUserInteractionEnabled:NO];
[UIView setAnimationDelegate: toView];
[UIView setAnimationDidStopSelector:@selector(setUserInteractionEnabled:)];
[toView setUserInteractionEnabled:YES];
*************** IT DOESN'T WORK AT ALL ***************/
// Remove the interaction
[toView setUserInteractionEnabled:NO];
[fromView setUserInteractionEnabled:NO];
// Create the animation
[UIView animateWithDuration:0.4 animations:^{
    [fromView performSelector:@selector(removeFromSuperview)];
    }
    completion:^(BOOL finished){
        [UIView animateWithDuration:0.4 
        animations:^{ 
            C6Log(@"finished");
            [toView performSelector: @selector(setUserInteractionEnabled:)];
        }];
    }];

The "toView" is removed instead of the "fromView" is removed 🙁
The buttons continue to be interactive during the animation

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:14:29+00:00Added an answer on June 5, 2026 at 5:14 pm

    I ended up creating a Category extension to UIView… and it finally works!

    UIView+Animated.h code

    #import <UIKit/UIKit.h>
    
    @interface UIView (Animated)
    
    - (void) finishedAnimation;
    
    @end
    

    UIView+Animated.m code

    #import "UIView+Animated.h"
    
    @implementation UIView (Animated)
    
    - (void) finishedAnimation{
        C6Log(@"FinishedAnimation!");
        [self removeFromSuperview];
        [[UIApplication sharedApplication] endIgnoringInteractionEvents];
    }
    
    @end
    

    Then, I #imported this extension in my coordinating controller:

    C6CoordinatingController.h partial code

    #import "UIView+Animated.h"
    

    And called the selector in setAnimationDidStopSelector:

    C6CoordinatingController.m partial code

    // Create the delegate, so the "fromView" is removed after the transition
    [UIView setAnimationDelegate: fromView];
    
    // Ignore interaction events during the animation
    [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
    
    // Set the transition duration
    [UIView setAnimationDuration: 0.4];
    
    // Call UIView+Animated "finishedAnimation" method when animation stops
    [UIView setAnimationDidStopSelector:@selector(finishedAnimation)];
    

    So, I ended up using @jaydee3 and @Mundi concepts and it works like a charm!

    Thank you guys!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.