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 8327553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:09:04+00:00 2026-06-09T01:09:04+00:00

I’m coding an iPhone TabBar Project with UiNavigation, the first view contain UIScrollView and

  • 0

I’m coding an iPhone TabBar Project with UiNavigation, the first view contain UIScrollView and the scrollview contain views every subview contain imageview,anUiImage and a UiButton follows
is the function that build the first screen

//*******************************************************
//*            Build the main screen                    *
//*******************************************************
-(void) buildScreen{
    sing.viewsArray = [[NSMutableArray alloc]init];

    int Vve = 10;
    int Vho = 10;
    int wi = 95;
    int hi = 95;
    int ArrayIndex = 0;
    for (int i = 0; i < 5; i++) {

        for (int j = 0; j < 3; j++) {

            staticView = [[UIView alloc] initWithFrame:CGRectMake(Vve, Vho, 100, 100)];
            [staticView setTag:ArrayIndex];

            staticImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[sing.stdPicArray objectAtIndex:ArrayIndex]]];
            [staticImage setFrame:CGRectMake(0, 0, wi, hi)];
            [staticView addSubview:staticImage];

            viewButton = [UIButton buttonWithType:UIButtonTypeCustom];
            viewButton.frame = CGRectMake(0, 0, wi, hi);
            [viewButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
            [viewButton setTag:ArrayIndex];
            [sing.buttonsArray addObject:viewButton];

            [staticView addSubview:viewButton];
            [sing.viewsArray addObject:staticView];

            [MainScroll addSubview:[sing.viewsArray objectAtIndex:ArrayIndex]];

            Vve += 100;
            ArrayIndex++;
        }
        Vve = 10;
        Vho += 100;
    }
}

When I click on the UiButton I want to add another UIView to the UIScrollView and make a “UIViewAnimationTransitionFlipFromLeft” when the view is added to the scroll view
tried the following code

-(void)animateFlip{    
    [UIView transitionWithView:flipViewBack
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    animations:^{ [self.view addSubview:flipViewBack]; }
                    completion:^(BOOL f){ }];
}

didn’t work just added the flipViewBack

-(void)animateFlip{     
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft        
                           forView:self.flipViewFront 
                             cache:YES];
    [MainScroll addSubview:flipViewFront];
    [UIView setAnimationDidStopSelector:@selector(flipAnimationDidStop:finished:context:)];
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];
}

didn’t work just like the other one, the next code did flip the main view with the view I wanted, but it didn’t flip only the the view I want

-(void)animateFlip{
    [UIView beginAnimations:nil 
                    context:nil];
    [UIView setAnimationDuration:1.0];

    [UIView transitionFromView:self.view 
                        toView:flipViewBack 
                      duration:2 
                       options:UIViewAnimationOptionTransitionFlipFromBottom 
                    completion:NULL];
    [UIView setAnimationDidStopSelector:@selector(flipAnimationDidStop:finished:context:)];
    [UIView setAnimationDelegate:self];

    //set transformation

    [UIView commitAnimations];

}

Does any body know how to do it’ I looked everywhere and all the code I found didn’t work for me

Thanks

I tried another option suggested in this link
iPhone subview flip between 2 views and it didn’t work for me

this is the function that I use on click in the last 3 lines im adding to the flipView (container) the flipViewFront view then I add the flipView to the mainScroll view and then I go to execute the animation in the animateFlip that I copied from your sample

    //*******************************************************
//*            Click on the picture as button           *
//*******************************************************
-(void) buttonClick:(id) sender{
    UIButton *button = (UIButton *)sender;
    int row = [button superview].tag;
    NSLog(@"Button pressed tag: %i",row);
    self.flipView = [[UIView alloc]initWithFrame:CGRectMake(65, 130, 190, 190)];
    self.flipView.backgroundColor = [UIColor clearColor];

    self.flipViewBack = [[UIView alloc]initWithFrame:CGRectMake(65, 130, 190, 190)];

    self.flipViewFront = [[UIView alloc]initWithFrame:CGRectMake(65, 130, 190, 190)];
    self.flipViewFront.backgroundColor = [UIColor whiteColor];

    self.flipViewImage = [UIImage imageNamed:[sing.stdPicArray objectAtIndex:row]];
    self.filpImage = [[UIImageView alloc]initWithImage:self.flipViewImage];
    [self.flipViewBack addSubview:self.filpImage];

    self.flipCloseButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.flipCloseButton setFrame:CGRectMake(0, 0, 24, 24)];
    [self.flipCloseButton setImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateNormal];
    [self.flipCloseButton addTarget:self action:@selector(closwFlip:) forControlEvents:UIControlEventTouchUpInside];
    [self.flipViewBack addSubview:flipCloseButton];

    self.flipOkButton = [[UIButton alloc]initWithFrame:CGRectMake(30, 0, 190, 190)];
    [self.flipCloseButton addTarget:self action:@selector(continueTo:) forControlEvents:UIControlEventTouchUpInside];
    [self.flipViewBack addSubview:flipOkButton];
    [flipView addSubview:flipViewFront];
    [MainScroll addSubview:flipView];
    [self animateFlip];
}

found the problem, but not the answer, if it works directly from the ViewDidLoad it and the first view is on screen all is well and the flip works’ if I change it so that the want to add a view and flip it in one event it shows me the second(flipped) view without the flip

  • 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-09T01:09:06+00:00Added an answer on June 9, 2026 at 1:09 am

    Your problems seems to be that you are trying to animate the flip on the view before it is added to the view hierarchy.

    Instead you should add the back view to a common container view (that later will contain the front view) and then flip the container view while adding the front and removing the back, like this:

    // Container view is a view that is already added to your view hierarchy.
    // It contains the back view. The front view will be added to it.
    [UIView transitionWithView:containerView
                      duration:1.0
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{
                        [backView removeFromSuperview]; // This is already added to the container
                        [containerView addSubview:frontView]; // Not yet added ...
                    }
                    completion:NULL];
    

    Update

    This is all the code I wrote when answering this question. It works for me. If it still doesn’t animate for you then you probably haven\t set up your view hierarchy the same way.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        containerView = [[UIView alloc] initWithFrame:CGRectMake(30, 30, 100, 100)];
        [self.view addSubview:containerView];
    
        frontView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        [frontView setBackgroundColor:[UIColor orangeColor]];
        backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        [backView setBackgroundColor:[UIColor redColor]];
        [containerView addSubview:backView];
    
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                              action:@selector(flip)];
        [self.view addGestureRecognizer:tap];
    }
    
    - (void)flip {
        [UIView transitionWithView:containerView
                          duration:1.0
                           options:UIViewAnimationOptionTransitionFlipFromLeft
                        animations:^{
                            [backView removeFromSuperview];
                            [containerView addSubview:frontView];
                        }
                        completion:NULL];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.