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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:48:42+00:00 2026-06-15T23:48:42+00:00

recently I am doing some project on something like a flip card. I have

  • 0

recently I am doing some project on something like a flip card. I have two subviews inside the view controller and I would like to flip over the subview on click of a button. What I can achieve now is the whole view is flipping but I just want the subview ONLY =( Please let me know what wrong with my code…..;( Thanks guys

- (void)test: (id)sender{
[UIView transitionFromView:firstView
                    toView:secondView
                  duration:0.5f
                   options:UIViewAnimationOptionTransitionFlipFromRight
                completion:^(BOOL finished){
                    /* do something on animation completion */
                }];

}

- (void)viewDidLoad
{
   [super viewDidLoad];
   firstView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];
   secondView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];
   firstView.backgroundColor = [UIColor redColor];
   secondView.backgroundColor = [UIColor blueColor];
   UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   button.frame = CGRectMake(0, 0, 25, 25);
   [button addTarget:self action:@selector(test:)forControlEvents:UIControlEventTouchUpInside];
   [self.view addSubview:button];
   [self.view addSubview:secondView];
   [self.view addSubview:firstView];
}
  • 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-15T23:48:43+00:00Added an answer on June 15, 2026 at 11:48 pm

    Add a another view (I call it container) to self.view, and add the firstView to that instead of directly to self.view. You don’t need to add the second view at all — the transition does that for you.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        UIView *container = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];
        firstView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 250, 250)];
        secondView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 250, 250)];
        firstView.backgroundColor = [UIColor redColor];
        secondView.backgroundColor = [UIColor blueColor];
        UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button.frame = CGRectMake(0, 0, 25, 25);
        [button addTarget:self action:@selector(test:)forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        [container addSubview:firstView];
        [self.view addSubview:container];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing some testing on a project that I recently started building
I have Java experience and recently am doing some C++ coding. My question is
Recently I'm doing some work with two Series in pandas: The first Series contains
I'm doing some research for my project where I'm gone have a shopping cart.
Project Euler I have recently begun to solve some of the Project Euler riddles.
Until recently we were using Inno Setup for our installations, something I would like
I have recently started doing some ActionScript/Flex programming and I am... Surprised... By the
I recently have done some refactoring to my project and I receive the following
I am doing some practice work by expanding on a homework project I recently
Recently I started doing a C++ project, and started it using the internal building

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.