0

In my application i set some animations in View1's view load() ,At first launch its working propely,if im pushed into otherview ,and while pop into view1 its not animating,What shoud i do for animate while pop view from other view?here my view did load code,

 - (void)viewDidLoad
{
artext=[[NSMutableArray alloc] init];
arimage=[[NSMutableArray alloc] init];
arsound=[[NSMutableArray alloc] init];

[super viewDidLoad];
[self copysqlitetodocuments];
[self Readthesqlitefile];   
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage     imageNamed:@"classroom.png"]];

}

i tried with

  - (void)viewDidAppear:(BOOL)animated
 {
 [self buttonmover];
 [super viewDidAppear:animated];
  }

its not working,Can any one pls help me to solve this problem

iosdev
  • 277
  • 8
  • 19
  • my buttonmover function gives animation,i tried it with view didappear its shows oly in first launch,Wen i pop from other view its not showing the animation? @vishy – iosdev Oct 19 '12 at 11:07
  • show us the button mover function, hw u r performing animations..? – vishy Oct 19 '12 at 11:35

3 Answers3

0

If you want to execute code when the view appears (e.g. an animation), -viewDidLoad is the wrong place to do it.

You should probably use:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    // ...
}
Mike Weller
  • 45,401
  • 15
  • 131
  • 151
0

Try in viewWillAppear

  -(void)viewWillAppear:(BOOL)animated
 {
  artext=[[NSMutableArray alloc] init];
  arimage=[[NSMutableArray alloc] init];
  arsound=[[NSMutableArray alloc] init];

  [self copysqlitetodocuments];
  [self Readthesqlitefile];   
  self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"classroom.png"]];

 }
Anki
  • 589
  • 2
  • 13
  • 22
0

When your viewDidLoad method is called, the controller isn't yet in the view hierarchy, so the animations doesn't work.

You have to perform animations in viewWillApper, after implementing the method [super viewWillAppear]. Something like:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    artext = [[NSMutableArray alloc] init];
    arimage = [[NSMutableArray alloc] init];
    arsound = [[NSMutableArray alloc] init];

    [self copysqlitetodocuments];
    [self Readthesqlitefile];   
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"classroom.png"]];

}
Marco Pace
  • 3,820
  • 19
  • 38