only show half screen of controller using presentModalViewController - iphone

i have a UIViewController that is only about 260px tall(or at least the area i want viewable is 260 approx. height) and really just has a picker on it and a done button. I'm calling presentModalViewController to display it but its showing the whole view, when really i only want to show the picker and the done button bar above the picker,
not the black above the bar
, is there a way to show only this and not the whole view behind the picker when it is presented ?
alt text http://img202.imageshack.us/img202/1754/picker.jpg
not too much for code here, ....
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tipPickerController];
[self presentModalViewController:navigationController animated:YES];
let me know if i should post more code to get help, thanks

Direct answer to your question:
You don't have to use a full screen view (320 X 480). You might set the view for the exact size that you need (without the black part on the top).
My suggestion:
Set the view for full screen, but in addition set a transparent color for your top level view (instead of black).
This way the original view won't be interactive while the picker is visible...

I am on a quest for the same thing. I found these resources.
How to make a UIPickerView slide half way up the screen?
Add UIPickerView & a Button in Action sheet - How?
The short answer is that a modal view controller is not what you want to use for this. It will work on an iPad but on an iPhone/iPod the modal view controller kills the first view when you display it. That is why it is black. I dont have it working yet but I think these resources are just the think to help.
Hope it helps.

Related

Creating a View popup over another ViewController on iPhone

I am trying to make some kind of popup view when a button i pressed on the iPhone. And it would be nice if I could manage that popup view with a ViewController. I have found out that the UIPopoverController could have been the solution, but it seems that it only works on the iPad...
But anyway, are there any similar solutions for the iPhone?
I am using storyboard
Check out these repos on Github:
https://github.com/werner77/WEPopover
https://github.com/50pixels/FPPopover
Create a separate view controller and resize its xib file and make it look like a popup.
Then ADD this view controller as a subview, and also add it as childController too.
[self addChildViewController:self.popOverViewController];
[self.view addSubview:self.popOverViewController.view];
Now Make it hidden initially.
self.popOverViewController.view.hidden = YES;
If a user taps on Button then using fade in & Fade out animation you can hide/unhide it.
I can tell you how to fade in and fade out if you want to know it further, I hope you can do it easily.
In interface builder make a UIView size of the screen and then make another in that Uiview with the style, size and the such for your pop over. Make its class, hook everything together.
CustomPopUpView *view = [[CustomPopUpView alloc] initWithFrame.....]
Add this all to your UIViewController with
[self.view addsubview:view]
Then attach a tapGestureRecognizer to the back view that animates the whole view off screen when tapped. So now if they click off your pop over view it close it will animates it off screen.
Hope this makes sense.
BooRanger

Why do positions of my UI elements change on popViewController?

I recently started using interface builder, the problem i'm facing right now is when i use the back button of navigation controller, my UI elements' y axis go up by roughly 20-30 px, is there some setting i've to use to avoid this problem ? And they go up only when i use pushViewController, when i use popViewController it loads the way i need.
Code i'm using for pushing:
examVC=[[ExampleClass alloc] initWithNibName:#"ExampleClass" bundle:nil];
[[self navigationController] pushViewController:examVC animated:YES];
I'm attaching the images with the question. Please note how label has gone down about 20-30 px.
Why does this happen? What am i doing wrong ?
Thanks for all the help.
Edit : changed the screens for better clarity
I'm using pushing code on the round rect button.
Screen 1:UI elements set in my IB
Screen 2: How it looks when pushed from previous view
Screen 3: How it looks when popped from the "Next View"
My home view controller had the navigation bar hidden, the screen i posted was the second view which comes after the home view. I wanted to hide navigation bar in the first view only, so i had used :
- (void)viewDidDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
}
It caused the problem because i was showing the navigation bar again in viewDidDisappear, so the view would load first then the navigation bar would be shown causing it to overlap.
So i put the same code in viewWillDisappear, which removed the issue. As navigation bar did load before loading of the next view. Now the view loads just like i designed it in interface builder.
Hey I don't know whether it will work for you or not but in your IB change top bar None to Navigation Bar
Then adjust your element accordingly and tun the code.
I tried all of the suggestions here and none of them worked. My UI elements were always lower when popping back to my original view controller. The only thing that fixed this for me was going into my nib file in Interface Builder and turning off Auto Layout.

How can I restrict modalViewController in Landscape?

I am working on iPad application where I am showing some view in modalView controller.
In Landscape, when I click on UITextField for taking some input modalview controller goes up and keyboard appears.
But I have changed the height of modalViewController and I dont want the modalView goes up for keyboard. How can I do this? Any help?
In the UIViewController's code, where you move its modalViewController, check if the interface orientation is not landscape
if(([self.interfaceOrientation!=UIInterfaceOrientationLandscapeLeft])
&&([self.interfaceOrientation!=UIInterfaceOrientationLandscapeRight]))
//your code to repostion the view controlled by the modalViewController
I guess you have to use custom presentation code. You cannot change the scrollup behaviour, when the keyboard appears.
You could add a 1024*768 sized black transparent view on top of the window and then your view on top of this. But you would have to build your own borders around your view in that case. Probably there are some open-source implementations of a modal popover. You can search for that on cocoacontrols etc.

Full screen UIImage view

I have an application with a navigation bar and a tab bar. A user can navigate to a view which displays images in a scroll view. I'd like to have the same behavior as the iPhone photo app: Nav bar at the top, tool bar at the bottom, which will hide or show based upon a tap.
I'm moving my view to the window object in order to achieve full screen mode. This works fine:
myView = [self.view retain];
self.view = nil;
[window addSubview:myView];
But when I want to redisplay the Nav & tool bar, I run into a problem. The bars show fine, but the view is empty, and I can't seem to add any content to the view:
[myView removeFromSuperview];
self.view = myView;
I got a lot of good info from this post
but can't quite get the right combination.
By simply setting the controller's view, you aren't adding it as a subview to anything else, so it will never appear.
Moving views around like this can get a little tricky. I recommend that you not move the view from one to the other, but instead have two UIViews. Add second UIView to the window's subview and set it to hidden=YES initially. When you want to show it, set the image for the UIImageView, and then set the hidden property to NO.
what's wrong with just using setNavigationBarHidden: animated: and setToolbarHidden:animated:?

How to prevent view resizing/transform when UINavigationBar hides/shows

I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)