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 NSLog开发者_如何转开发s 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 :
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 ?
Try removing just the three animation messages.
If it moves (I think it won't, but ...)
- Try passing in @"moveup" as the first argument to beginAnimations
- Try using setAnimationCurve
If it doesn't move
- Is the view inside another view that sets a layout for this view?
- 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.
精彩评论