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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:34:08+00:00 2026-06-08T14:34:08+00:00

I have a very small animation I want to do by moving a view’s

  • 0

I have a very small animation I want to do by moving a view’s frame using blocks (rather than the animation headers).

My view hierarchy is quite big so I will explain everything in regards of the specific view I want to animate.

The biggest view is the one that takes the whole screen, so it is 320×480 points. Inside this view, I have another view called “keypadContainerView” that is 320×200 points, located on 0, 261 and it appears at the bottom of the screen. This keypadContainerView has a subview called keypadView, which has a bunch of small buttons as subviews.

Biggest View -> KeypadContainerView -> keypadView -> UIbuttons.

An screenshot:

enter image description here

Although this could go without saying, the keypad there is the keypadContainerView, with is’t keypadView and buttons. I need this hierarchy because I’m aiming for eye candy here, and each layer has a different background.

The way I create and deal with that view is here:

    keypadViewContainer = [[[UIView alloc] initWithFrame:CGRectMake(0, 261, 320, 200)] autorelease]; //(Original is 0, 261, 320, 200)
    keypadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    [keypadViewContainer addSubview:keypadView];

//Add the buttons

[self.view addSubview:keypadViewContainer];

And this is how I’m trying to animate it:

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:5.0 animations:^{
        self.keypadViewContainer.frame = CGRectMake(0, 0, 320, 200);
    } completion:NULL];
}

What is funny is that if I NSLog something in the animations: parameter, I actually get some output so the method is definitely getting called. It’s just not animating anything at all.

The whole controller code is here, in case you need it:

//UnlockKeyboardViewController
//------------------------------------------------------------------------
@interface UnlockKeyboardViewController : UIViewController
{
    NSArray *buttons;
    NSArray *passcodeFields;

    UIImage *buttonBackgroundImage;
    UIImage *buttonBackgroundHighlightedImage;
    UIImage *middleButtonBackgroundImage;
    UIImage *middleButtonBackgroundImageHighlighted;
    UIImage *screenBackgroundImage;

    UIImage *infoViewContainerImage;
    UIImage *keypadViewContainerImage;
    UIImage *passcodeFieldsContainerImage;

    UIImage *infoViewImage;
    UIImage *passcodeViewImage;

    UIView *infoViewContainer;
    UIView *keypadViewContainer;
    UIView *passcodeFieldsContainer;

    UIView *infoView;
    UIView *keypadView;
    UIView *passcodeFieldsView;

    UIView *infoToDisplayView; //The view the programmer passes to show in infoView.
}

@property(nonatomic, retain)UIImage *buttonBackgroundImage;
@property(nonatomic, retain)UIImage *buttonBackgroundHighlightedImage;
@property(nonatomic, retain)UIImage *screenBackgroundImage;
@property(nonatomic, retain)UIImage *keypadViewBackgroundImage;
@property(nonatomic, retain)UIImage *infoViewContainerImage;
@property(nonatomic, retain)UIImage *keypadViewContainerImage;
@property(nonatomic, retain)UIImage *passcodeFieldsContainerImage;
@property(nonatomic, retain)UIImage *infoViewImage;
@property(nonatomic, retain)UIImage *passcodeViewImage;
@property(nonatomic, retain)UIView *infoToDisplayView;

//Properties for container views.
@property(nonatomic, retain)UIView *infoViewContainer;
@property(nonatomic, retain)UIView *keypadViewContainer;
@property(nonatomic, retain)UIView *passcodeFieldsContainer;
@end

@implementation UnlockKeyboardViewController
@synthesize buttonBackgroundImage = _buttonBackgroundImage;
@synthesize buttonBackgroundHighlightedImage = _buttonBackgroundHighlightedImage;
@synthesize screenBackgroundImage = _screenBackgroundImage;
@synthesize keypadViewBackgroundImage = _keypadViewBackgroundImage;
@synthesize infoViewContainerImage = _infoViewContainerImage;
@synthesize keypadViewContainerImage = _keypadViewContainerImage;
@synthesize passcodeFieldsContainerImage = _passcodeFieldsContainerImage;
@synthesize infoViewImage = _infoViewImage;
@synthesize passcodeViewImage = _passcodeViewImage;
@synthesize infoToDisplayView = _infoToDisplayView;

//Synthesizers for container views.
@synthesize infoViewContainer = _infoViewContainer;
@synthesize keypadViewContainer = _keypadViewContainer;
@synthesize passcodeFieldsContainer = _passcodeFieldsContainer;

-(void)loadView
{
    [super loadView];
    self.view.frame = CGRectMake(0, 0, 320, 480);
    _unlockKeyboardBundle = [NSBundle bundleForClass:[self class]];
    buttonBackgroundImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"button" ofType:@"png"]];
    middleButtonBackgroundImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"middleButton" ofType:@"png"]];
    buttonBackgroundHighlightedImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"pushedButton" ofType:@"png"]];
    middleButtonBackgroundImageHighlighted = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"pushedButtonMiddle" ofType:@"png"]];

    infoViewContainerImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"infoViewContainerImage" ofType:@"png"]];
    keypadViewContainerImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"keypadViewContainerImage" ofType:@"png"]];
    passcodeFieldsContainerImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"passcodeViewContainerImage" ofType:@"png"]];

    infoViewImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"infobackground" ofType:@"png"]];
    passcodeViewImage = [UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"passcodescreen" ofType:@"png"]];

    //self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[_unlockKeyboardBundle pathForResource:@"lockbackground" ofType:@"png"]]];

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    keypadViewContainer = [[[UIView alloc] initWithFrame:CGRectMake(0, 261, 320, 200)] autorelease]; //(Original is 0, 261, 320, 200)
    keypadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    [keypadViewContainer addSubview:keypadView];
    keypadViewContainer.backgroundColor = [UIColor colorWithPatternImage:keypadViewContainerImage];

    NSMutableArray *tempButtons = [NSMutableArray array];
    self.view.opaque = YES;

    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setTitle:@"1" forState:UIControlStateNormal];
    button1.frame = CGRectMake(0, 0, 106, 50);

    UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button4 setTitle:@"4" forState:UIControlStateNormal];
    button4.frame = CGRectMake(0, 50, 106, 50);

    UIButton *button7 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button7 setTitle:@"7" forState:UIControlStateNormal];
    button7.frame = CGRectMake(0, 100, 106, 50);

    UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancel setTitle:NSLocalizedString(@"cancel", @"Cancel string") forState:UIControlStateNormal];
    cancel.frame = CGRectMake(0, 150, 106, 50);

    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setTitle:@"2" forState:UIControlStateNormal];
    button2.frame = CGRectMake(106, 0, 108, 50);

    UIButton *button5 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button5 setTitle:@"5" forState:UIControlStateNormal];
    button5.frame = CGRectMake(106, 50, 108, 50);

    UIButton *button8 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button8 setTitle:@"8" forState:UIControlStateNormal];
    button8.frame = CGRectMake(106, 100, 108, 50);

    UIButton *button0 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button0 setTitle:@"0" forState:UIControlStateNormal];
    button0.frame = CGRectMake(106, 150, 108, 50);

    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button3 setTitle:@"3" forState:UIControlStateNormal];
    button3.frame = CGRectMake(214, 0, 106, 50);

    UIButton *button6 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button6 setTitle:@"6" forState:UIControlStateNormal];
    button6.frame = CGRectMake(214, 50, 106, 50);

    UIButton *button9 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button9 setTitle:@"9" forState:UIControlStateNormal];
    button9.frame = CGRectMake(214, 100, 106, 50);

    UIButton *cancelOrDelete = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelOrDelete setTitle:@"<-" forState:UIControlStateNormal];
    cancelOrDelete.frame = CGRectMake(214, 150, 108, 50);

    [tempButtons addObject:button1];
    [tempButtons addObject:button2];
    [tempButtons addObject:button3];
    [tempButtons addObject:button4];
    [tempButtons addObject:button5];
    [tempButtons addObject:button6];
    [tempButtons addObject:button7];
    [tempButtons addObject:button8];
    [tempButtons addObject:button9];
    [tempButtons addObject:button0];
    [tempButtons addObject:cancel];
    [tempButtons addObject:cancelOrDelete];

    buttons = [[NSArray arrayWithArray:tempButtons] retain];

    for(UIButton *theButton in buttons)
    {
        if([theButton.currentTitle isEqualToString:@"2"] || [theButton.currentTitle isEqualToString:@"5"] || [theButton.currentTitle isEqualToString:@"8"] || [theButton.currentTitle isEqualToString:@"0"])
        {
            [theButton setBackgroundImage:middleButtonBackgroundImage forState:UIControlStateNormal];
            [theButton setBackgroundImage:middleButtonBackgroundImageHighlighted forState:UIControlStateHighlighted];
        }else
        {
            [theButton setBackgroundImage:buttonBackgroundImage forState:UIControlStateNormal];
            [theButton setBackgroundImage:middleButtonBackgroundImageHighlighted forState:UIControlStateHighlighted];
        }
        [keypadView addSubview:theButton];
    }
    [self.view addSubview:keypadViewContainer];

    passcodeFieldsView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0,320, 110)] autorelease];
    passcodeFieldsContainer = [[[UIView alloc] initWithFrame:CGRectMake(0, 151, 320, 110)] autorelease];
    passcodeFieldsContainer.backgroundColor = [UIColor colorWithPatternImage:passcodeFieldsContainerImage];
    passcodeFieldsView.backgroundColor = [UIColor colorWithPatternImage:passcodeViewImage];

    NSMutableArray *passTemps = [NSMutableArray array];

    UITextField *tf1 = [[[UITextField alloc] initWithFrame:CGRectMake(24, 27, 50, 50)] autorelease];
    UITextField *tf2 = [[[UITextField alloc] initWithFrame:CGRectMake(98, 27, 50, 50)] autorelease];
    UITextField *tf3 = [[[UITextField alloc] initWithFrame:CGRectMake(172, 27, 50, 50)] autorelease];
    UITextField *tf4 = [[[UITextField alloc] initWithFrame:CGRectMake(246, 27, 50, 50)] autorelease];

    [passTemps addObject:tf1];
    [passTemps addObject:tf2];
    [passTemps addObject:tf3];
    [passTemps addObject:tf4];

    passcodeFields = [[NSArray arrayWithArray:passTemps] retain];

    for(UITextField *theTf in passcodeFields)
    {
        theTf.borderStyle = UITextBorderStyleBezel;
        theTf.backgroundColor = [UIColor whiteColor];
        theTf.enabled = NO;
        theTf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        theTf.textAlignment = UITextAlignmentCenter;
        theTf.adjustsFontSizeToFitWidth = YES;
        theTf.alpha = 0.7;
        theTf.secureTextEntry = YES;
        [passcodeFieldsView addSubview:theTf];
    }

    [passcodeFieldsContainer addSubview:passcodeFieldsView];

    [self.view addSubview:passcodeFieldsContainer];

    infoView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 151)] autorelease];
    infoView.backgroundColor = [UIColor colorWithPatternImage:infoViewImage];
    infoViewContainer = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 151)] autorelease];
    infoViewContainer.backgroundColor = [UIColor colorWithPatternImage:infoViewContainerImage];

    [infoViewContainer addSubview:infoView];

    [self.view addSubview:infoViewContainer];

    [pool drain];
}
-(void)viewDidLoad
{
    [super viewDidLoad];
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:5.0 animations:^{
        self.keypadViewContainer.frame = CGRectMake(0, 0, 320, 200);
    } completion:NULL];
}

-(void)dealloc
{
    [buttons release];
    [passcodeFields release];
    [buttonBackgroundImage release];
    [buttonBackgroundHighlightedImage release];
    [screenBackgroundImage release];
    [infoView release];
    [keypadView release];
    [passcodeFieldsView release];
    [infoViewContainerImage release];
    [keypadViewContainerImage release];
    [passcodeFieldsContainerImage release];
    [infoViewImage release];
    [passcodeViewImage release];
    [infoToDisplayView release];
    [super dealloc];
}
@end

I have a small feeling it may have something to do with the way I’m dealing with my views, so there’s the whole source code.

Any help with this will be highly appreciated.

  • 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-08T14:34:13+00:00Added an answer on June 8, 2026 at 2:34 pm

    Instead of those :

    keypadViewContainer = [[[UIView alloc] initWithFrame:CGRectMake(0, 261, 320, 200)] autorelease]; 
    

    Use

    Self.keypadViewContainer = .....
    

    and your @synthesize are wrong.
    You declare iVars explicitly without underscore,
    But use synthesize to create underscored iVars.

    So your properties correspond to
    _keypadViewContainer
    but in your loadView you assign to keypadViewController

    Quickest fix: just use @synthesize instead of synthesize = …
    (that is only if you don’t use Xcode 4.4!)

    Best fix: get rid of the explicit iVar declaration and
    Make sure to use _keypadViewContainer etc. when you access iVar directly like in dealloc.

    Ideal fix: use ARC and use IB to build your keypad interface (why don’t you btw?)

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

Sidebar

Related Questions

I have a very small problem, I want to submit my code using jQuery
I have vales with very small difference like... 0.000001. I want to visualize them
I have a very small object graph that I'm using: public struct Address {
I have a very small app which i am using to learn design patterns.
I have a sprite animation, a small cannon rendered using a 3D app. I
i have a very small utilty app written in c# that works fine on
I have a very small form where a user can enter their zip code
I have a very small office environment, and my team sends created pdfs to
I have a very small program: public static void main(String[] args) { Queue<String> queue
I have to multiply a very small sized matrix ( size - 10x10 )

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.