views:

59

answers:

1

Ok, this might sound simple, but somehow I can't get this function to work .

- (void)setViewMovedUp:(BOOL)movedUp {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];

    CGRect rect = self.view.frame;
    NSLog(@"%f",self.view.frame.size.height);
    if (movedUp)
    {
        NSLog(@"test Moved Up");
        rect.origin.y += 60;
        rect.size.height -= 300;
    }
    self.view.frame = rect ;
    NSLog(@"%f after:",self.view.frame.size.height);

    [UIView commitAnimations];

}

All the NSLogs are printing results fine and "Test Moved Up" appears so I know there is nothing wrong upstream .

This function is part of the implementation file of my MainViewController ( which manages the root view of my Window app ) .

I assume I have to call : self.view.frame, right ?

No error or warning appears, but it just doesn`t move despite printing out the logs correctly ..

Edit, this is the hierarchy in IB :

alt text


Edit again : I'm actually wondering if I'm allowed to move that view up, are we allowed to move views up if they are at the top of the hierarchy ? Then what would be revealed behind ?

A: 

Try removing just the three animation messages.

If it moves (I think it won't, but ...)

  1. Try passing in @"moveup" as the first argument to beginAnimations
  2. Try using setAnimationCurve

If it doesn't move

  1. Is the view inside another view that sets a layout for this view?
  2. Are you calling this inside the main thread (not in a background thread)

EDIT: Update

You shouldn't need to do this, but try

[self.view setNeedsDisplay];

If that doesn't work, try it on the window. Changing the frame is supposed to do this automatically.

Lou Franco
So, it doesn`t move just removing the three animation messages . The View is not inside any other view, it does however contains views inside . As far as I know this is executing inside the main thread . See diagram here : https://cacoo.com/diagrams/FFej49F5nTWCca4o
Julz
What in your app causes this to be called?
Lou Franco
The button in the scroll view
Julz
[self.view setNeedsDisplay]; didn`t work unfortunately . When you say try it on the window it would be as simple as : [self.window setNeedsDisplay] right ? because that`s giving me : "Request for member "window" is something not a structure or union"
Julz
[self.view.window setNeedsDisplay] -- probably won't work. Are you sure that this viewcontroller is set up correctly. Does any other change to the view work?
Lou Franco
Hey Lou, thanks for your help on this, the [self.view.window setNeedsDisplay] didn`t work either . The ViewController is connected to the App Delegate in the referencing outlet and to the Main View as its outlet. I also have a modal View Transition on this ViewController an it works just fine :( I just don`t see what else it could be !
Julz