presentmodalviewcontroller - how to not to make it cover entire screen?
I have a tab bar and a search button on its toolbar. So now whenever the user clicks the search i would like a view to come up (presenetmodalviewcontroller) but present modal view controller covers entire screen is there any way that it covers only the present view (ie view in the current tab bar)? now how 开发者_如何学Pythoncan I accomplish this?
thanks, Tushar Chutani
By definition, a modal view controller is meant to "interrupt" the current flow of an application for something else (requesting a user/pass, asking for a contact to send an email, etc). You can read more about this in the View Controller Programming Guide.
You are better off using a navigation stack (UINavigationController
) inside the current tab to handle other viewControllers that must be presented to the user. Here's another stack overflow question on how to place navigation controllers in a tab bar application. With a navigation stack, you can push view controllers (pushViewController:animated:
), and manage an indefinite depth of viewControllers for a single tab item.
One option is for the view that's inside the tabbar to be within a NavigationController. Then , instead of presentModalViewController, you would pushViewController onto the stack. That would leave the tabBar at the bottom visible and it allows you to navigate back.
That does however add a navigationBar to the top. Not sure if that's a problem for your app.
So this is how I was able to do not the best code but it works What I have pretty much done is addsubview to a uiimageview (should have used UIWindow but who cares?)
-(void)revers{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
NSLog(@"Revenre is called");
otherViewImage.transform = CGAffineTransformMakeTranslation(0,-380);
[otherViewImage addSubview:hup.view];
[UIView commitAnimations];
}
精彩评论