I'm writing an App where I want a view/viewController to slide in from bottom.
I've tried using the "presentModalViewController"-method. Problem is that I need the new viewController to be seethrough, any way to do that?
I've also tried just switching to a view, where the background is seethroug, instead of a viewController using this code:
[UIView beginAnimations:@"SlideInFromBottom" context:nil];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatCount:0];
[UIView setAnimationRepeatAutoreverses:NO];
if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {
ToolbarView.frame = CGRectMake(0, 44, 320, 460);
ToolbarView.frame = CGRectMake(0, 0, 320, 460);
} else if (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
ToolbarView.frame = CGRec开发者_JAVA技巧tMake(0, 44, 320, 460);
ToolbarView.frame = CGRectMake(0, 0, 320, 460);
} else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
ToolbarView.frame = CGRectMake(0, 44, 480, 300);
ToolbarView.frame = CGRectMake(0, 0, 480, 300);
} else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
ToolbarView.frame = CGRectMake(0, 44, 480, 300);
ToolbarView.frame = CGRectMake(0, 0, 480, 300);
}
The problem is that if is switch from portrait to landscape it doesn't line up and the animation looks poorly every first time switching view after rotating my device, because it needs to line up.
So any suggestions would be appreciated :)
PS: the view I'm trying to load only contains a Toolbar.
If you want to do your own animations, you need to set it up like this:
ToolbarView.frame = START POSITION
[UIView beginAnimations: ...];
ToolbarView.frame = END POSITION
[UIView commitAnimations];
In other words, "begin" looks at the views and establishes starting positions; "commit" looks again and establishes final positions.
You shouldn't have to mess around with interfaceOrientation; the ToolbarView's orientation will match its superview, so just add it as a subview of the top view controller's view.
Finally, you may want to look at UIControl's inputView
property. Basically, you can make a custom control and if it becomes first responder, iOS will take care of sliding up the inputView from the bottom of the screen. (If you want to go that route you'll have to do some more research, as its outside the scope of this question.)
精彩评论