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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:11:46+00:00 2026-05-29T05:11:46+00:00

I create the views, UI elements etc programmatically. I’m trying to animate views when

  • 0

I create the views, UI elements etc programmatically.
I’m trying to animate views when they are added or removed. The problem is that only UIButton *button is being animated and it is animated wrong. I mean the button title comes from the top and the button itself comes from the right of the screen.

Please see the code below

AppDelegate.h

#import <UIKit/UIKit.h>
#import "TViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
    TViewController *tv;
}

@property (strong, nonatomic) TViewController *tv;
@property (strong, nonatomic) UIWindow *window;

@end

AppDelegate.m
…..

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.window.backgroundColor = [UIColor whiteColor];
    self.tv = [[TViewController alloc]initWithNibName:@"TViewController" bundle:nil];
    self.window.rootViewController = self.tv;

    [self.window makeKeyAndVisible];
    return YES;
}

TViewController.h

#import <UIKit/UIKit.h>
#import "Elements.h"
@interface TViewController : UIViewController
{
    Elements *el;
}

@property (nonatomic, retain) Elements *el;
@end

TViewController.m

-(void)loadView
{
    self.view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].applicationFrame];

    self.el = [[Elements alloc] 
               initWithNibName:@"Elements" 
               bundle:nil];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:3.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.superview cache:YES];
    [self.view addSubview:self.el.view];
    self.view.backgroundColor = [UIColor grayColor];
    [self.view removeFromSuperview];
    [UIView commitAnimations];

}

Elements.m

self.view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].applicationFrame];

    UILabel *howManyUsersLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 20, 300, 150)];
    howManyUsersLabel.text = @"Label ...";
    [self.view addSubview:howManyUsersLabel];


    UIPickerView *playersPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(10, 150, 250, 100)];
    playersPickerView.delegate = self;
    playersPickerView.showsSelectionIndicator = YES;
    [self.view addSubview:playersPickerView];


    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(20, 370, 280, 50);
    [button setTitle:@"Button" forState:UIControlStateNormal];

    [self.view addSubview:button];
  • 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-05-29T05:11:47+00:00Added an answer on May 29, 2026 at 5:11 am

    Transitions have to be applied to a view that doesn’t get removed or added during the transition. You are adding the transition to self.view, but then you are removing self.view during the transition.

    Try adding the transition to self.view.superview instead, like this:

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.superview cache:YES];
    

    If that still doesn’t work, are you sure this code is right:

    [self.view addSubview:self.el.view];
    self.view.backgroundColor = [UIColor grayColor];
    [self.view removeFromSuperview];
    

    Literally, this code is saying:

    add self.el.view as a subview to self.view
    set background colour of self.view to gray
    remove self.view from the screen
    

    That means the first two lines are pointless because everything you do to the view is wiped out when you remove it from the screen. And removing the view is a weird thing to do during loadView – the end result would be the view would be nil after loading.

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

Sidebar

Related Questions

I wanted to create a very simple method that switches between views in a
I create class that extends LinerLayout and add many elements on view, also I
Sorry for the Newb-ness. I want to create a list of view elements in
I would like to create views, similar to MVC, whereas I can plug HTML
I've got a (SQL Server 2005) database where I'd like to create views on-the-fly.
Ideally I'd like to be able to create the views in Interface Builder and
We are investigating how to create data entry views from a dynamic list of
In my django views i have the following def create(request): query=header.objects.filter(id=a)[0] a=query.criteria_set.all() logging.debug(a.details) I
I want to create a FlipPanel, which provides two different views of the same
I have my views render to route requests like /controller/action (for instance, /Page/Create), so

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.