How do I make the modal view only come up half way? - iphone

So I have an app where you play a game, and at the end it asks you your name for recording of the high score. I would like to use a modal view to accomplish this, but I am experiencing some hiccups along the way. So far, all I have is the modal view sliding up all the way to the top of the screen, but there isn't anything there yet, it's just blank:
UINavigationController *navController = [UINavigationController new];
[self presentModalViewController:navController animated:YES];
I have seen on several other iPhone apps, the ability to make the modal view come only half way up the screen (or less) and then have a textfield where you can receive input, such as for my high score list. How would I go about restricing the size of the modal view? And perhaps adding a textfield onto it? Any help would be appreciated! Thanks

What makes you think presentModalViewController was used?
You can do this quite easily with an UIViewController and animation.

Using Animation, a sample would look like something like this:
//Move Screen UP:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x, (self.view.frame.origin.y - kTextView_Keyboard_Offset), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
Where the "kTextView_Keyboard_Offset is defined in my Contants. You would specify/replace with your Offset value equal the number of pixels in the direction that you would like to move.

Define a full-screen view with a transparent background - then put the obscuring content wherever you like.
Then you just bring it up as you would any other modal view.

Related

UIView animation in iphone retina display is not smooth

I want a roll-up animation for the uiview. So i am animating a mainscrollview and a rollupboard. So in the viewDidLoad i set the frame of these two views as:
dashRollUpStand=[[UIImageView alloc]initWithFrame:CGRectMake(0,346,320,0)];
mainScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(10,346,300,0)];
And i also have many subviews for this mainScrollView.
Now i am loading this view with a roll-up animation using the following code:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIAnimationCurveLinear];
[dashRollUpStand setFrame:CGRectMake(0,0,320,346)];
[mainScrollView setFrame:CGRectMake(10,9,300,337)];
[UIView commitAnimations];
This rollup animation is working fine in iphone. But on iphone retina display this animation is not at all smooth. So how can i make it smooth in iphone retina display.
Is there a reason why you are adding your views in viewDidLoad and having them offscreen?
It seems to me that you should do it like this. In the code below containerView is the view that contains your views, toView is the view you are flipping to and fromView is the view you are flipping from.
[UIView transitionWithView:containerView
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[fromView removeFromSuperview];
[containerView addSubview:toView];
}
completion:NULL];
I also chose to use the block-based animation/transition API which is the recommended way since iOS 4.
EDIT:
Since you are not actually transitioning the view, even though your original code did. You could just use a normal animation block instead
[UIView animateWithDuration:1.0
animations:^{
[dashRollUpStand setFrame:CGRectMake(0,0,320,346)];
[mainScrollView setFrame:CGRectMake(10,9,300,337)];
}
completion:NULL];
The problem is not the kind of animations you are using, but more probably what you have iside your views. First of all try to make sure that subviews inside your animated view are opaque, opaque is a property of UIView, but it is overridden if the alpha of the view is less that 1. The rendering system requires more clicles to blend clear views, if you can go for opaque.

UIView not displaying in landscape

I have a window with a UIView and a transition to another UIView. But when I do the transition, the window to transition to is displayed in portrait, and after the transition is finished, it goes to landscape.. But I want the UIView to be in landscape BEFORE the transition because otherwise the screen looks f*cked up because the background image is made for landscape mode. Here is my code:
UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES];
[[oldView view] removeFromSuperview];
[window addSubview:newView.view];
[UIView commitAnimations];
The orientation property of the newWindow is set to landscape in the interface builder, and also in the superview...
What am I doing wrong??
Thanks in advance!
First of all, you should not use multiple window, it will never give you the result you are expecting...
You can easily do the same thing with one window and 2 UIViews.
Solved... I had to put the commitAnimations part above the addSubview:newView
Hope this helps everyone with the same issue....

Flipping UIView inside UIScrollView

In photo app of iphone you can see smooth scrolling to the other picture with finger flicking. Is it possible to allow individual view to be 'flipped' (or rotated) to show its back side ? Found that UIScrollView is used for smooth scrolling and found the code for flipping UI. Outside of UISCrollView I got the flip to work using the code below. But once inside UIScrollView this doesn't work - it executes but UI never switches.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:myView cache:YES];
[UIView setAnimationDuration:1.0];
[myView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
Perhaps this is not suppose to work this way. What is the recommended way or technique to have flippable individual views inside the UIScrollView ?
Never mind. It does work. Once inside UIScrollView there were several UIViews and I needed to make sure I grab the pointer to current UIView. The above code works in this case as well. I was doing a flip on a view which was hidden :)

iPhone SDK page flip and Page curl

I got the page flips and curls to work. I'll describe what happens...
I build and Go
The App opens in simulator
I press a button and the page curls to page 2... but when it gets to page 2 the page drops down a bit. Why does this happen?
if you're using view controllers, you shouldn't be adding their views manually, but should be using -[UINavigationController pushViewController:animated:]. There are ways to use these two techniques together, but that might be more trouble than it's worth. I'd suggest not using a viewController for your second, curled in view, until you're a bit more comfortable with the UIXXXController design pattern. Just add an outlet in your primary viewController for the paged-in view and hook it up in IB.
- (IBAction)goToSecondView {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view]cache:YES];
[self.view addSubview:secondViewController.view];
[UIView commitAnimations];
}

How do I get the UIPickerView to slide up over another view?

I am looking for a way to slide a UIPickerView (and UIDatePickerView) up over a view (UITableView in particular) when a particular button press takes place.
I understand how to get the events for clicks into the UITableView, but there doesn't seem to be a good way to have the UIPickerView slide up on top of it...
All the examples I have seen so far just have it snapped to the bottom of another view and I am able to do this without issue.
Thoughts?
Thanks in advance.
Modally presented view controllers slide up from the bottom to cover the current view.
See the documentation for -presentModalViewController:animated: in the UIViewController Class Reference. You would invoke this method on your UITableViewController and pass the UIPickerViewController as the first parameter and YES as the second.
An example of what Ben mentions above (Animation Blocks) is the following, which will animate to a subview.
UIWindow *window = [[Director sharedDirector] window];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:(UIViewAnimationTransitionCurlDown)
forView:window
cache:YES];
[window addSubview:aView];
[UIView commitAnimations];
Have you tried using UIView's animation blocks do do this? See the Apple docs on +[UIView beginAnimations:context:] and +[UIView commitAnimations]. Basically, wrap your calls to display the UIPickerView in these calls, and you can slow it down a bit.