0

In my viewDidAppear i"m changing the frame of one of my ImageViews. The view and all the other methods will not show it until i will [self viewDidAppear] it. I feel its not right, is there some reloadData message ?

Thank you.

Yevgeni
  • 1,533
  • 17
  • 32
  • 1
    You should not be calling UIViewController methods manually, generally speaking. Ideally you would define a method that handles the setting up of all your views, and call that method within viewDidAppear, and wherever you want to 'reload' the view. – Tim Oct 14 '13 at 14:14

3 Answers3

1

Exactly, calling [self viewDidappear] yourself is not right.

If you need to change the frame of the views while being on the view, create a method yourself that you can call every time you want, or use viewDidLayoutSubviews;

When the bounds change for a view controller’s view, the view adjusts the positions of its subviews and then the system calls this method. However, this method being called does not indicate that the individual layouts of the view’s subviews have been adjusted. Each subview is responsible for adjusting its own layout.

Also, check that your method has a correct implementation:

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

    //Your code
}
Antonio MG
  • 20,382
  • 3
  • 43
  • 62
  • Ok so i"m creating a method and call in through the viewDidAppear, but how is it different? how the method will "reload" the view? – Yevgeni Oct 14 '13 at 16:25
  • What if in my application I am creating UI programmatically and in the viewController, I am adding all views from viewDidLoad method? In this case, if I create common method then those views will get instantiated & added multiple times. So to avoid this I will have to remove each view, dealloc it and execute that method again. So there should be a better alternative to this? – ViruMax Oct 19 '16 at 09:05
0

It would be better to change your image view's frame in viewDidLayoutSubviews.

Ell Neal
  • 6,014
  • 2
  • 29
  • 54
0

You probably implemented the wrong function. The proper method signature is:

- (void)viewDidAppear:(BOOL)animated

not just viewDidAppear.

Alexander
  • 8,117
  • 1
  • 35
  • 46