0

I'm having some trouble with moving a view:

- (void)viewDidLoad {

    CGRect newFrame = self.popUp.view.frame;
    newFrame.origin.y = self.view.bounds.size.height;
    self.popUp.view.frame = newFrame;

    [[self view] addSubview:[self.popUp view]];

    [super viewDidLoad];
}

This should put the subview popUp below the current screen but it does not seem to be moving it. I'm almost positive this was working pre-4.2. Any ideas as to what might be going on? Sorry for the vagueness. If you have any questions feel free to ask.

emachine
  • 1,135
  • 4
  • 17
  • 25

2 Answers2

0

Did you try moving [super viewDidLoad] to the top of the method? Where you call a superclass's method can affect the state of inherited vars.

Good post on this: `[super viewDidLoad]` convention

Community
  • 1
  • 1
Sam
  • 2,707
  • 20
  • 25
0

It looks like you are moving so the top of popUp.view is at the bottom of self.view. And then when you are adding popUp.view to self.view you are placing it "outside" of self.view. You can verify this by newFrame.origin.y = self.view.bounds.size.height - 100; and see if it shows up.

One reason that your view doesn't show up as it did before could be that you have changed clipsToBounds. I imagine it can also be some other drawing optimization taking place and not drawing views that are out bounds and not visible.

If you want your pop up to show up below a view I think a better approach would be to either place your pop up at the bottom of your view:

newFrame.origin.y = self.view.bounds.size.height - newFrame.size.height;

or by placing the pop up view in the superview of self.view. In that case you would probably want to handle the showing in the controller of the superview.

Robert Höglund
  • 10,010
  • 13
  • 53
  • 70