To explain what I'm looking for I'll give an example: In the Contacts app, when you click the Search field in the first row of the table view it will smoothly take over the entire screen (minus the status bar) including the Navigation Controller's title bar.
Edit: I've also realized that I'm pretty sure this is related to the UISearchDisplayController being within a UITableView which is within an NavigationController which is within a TabBarController. The problem is that the search display will only take up the tableviews size and not the navigation controller.
I've mimicked this in my program by using UIView animations and resizing the entire navigation controller's frame to start above the visible screen's view. See below:
-(void)SetNavContTitleVis:(BOOL)ishidden {
[UIView beginAnimations:#"frame" context:nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 0.3];
CGRect frameIn;
if (ishidden) {
frameIn = CGRectMake(0,-46,320,480);
} else {
frameIn = CGRectMake(0,0,320,480-46);
}
self.parentViewController.view.frame=frameIn
[UIView commitAnimations];
}
This works fine and gets the job done but it feels like a hack. Is there any simpler way to do this with search display controllers? I feel that this is a hack that will get me into trouble in the future if display sizes change or the Apple tablet comes out etc. I've looked around for a while but haven't found any simple setting that will force the UISearchDisplayController to take up the navigation controller's title bar smoothly.
The search bar should animate like that by default. Check out Apple's sample TableSearch.
Related
I have subclassed UINavigationBar so I can create a gradient to fill it. My problem is that when I present the Navigation Controller, while it animates from bottom to the top, the color of the button items on the navigation bar is still blue (the default one) and it only changes as it should when it finishes animating (when the Navigation Controller reaches the top). I have attached to pictures two help you understand what my problem is.
You put your change color code in animated method only so both together doing fine try this.
[UIView beginAnimations:nil context:nil];
[self.navigationController.navigationBar.tintcolor:[uicolor red color]];
[self.navigationController.navigationbaritem same code here only
[UIView commitAnimations];
I am working on an iOS app and am having trouble with a really tall UIView (2400px tall). The UIView contains a really long form that's been broken down into 5 parts. As the user completes one part of the form, I would like to slide the UIView up to reveal the next part. I present the UIView modally.
The problem that I am having is that when I slide up the UIView, the background slides up along with the objects in the first section and the next section is left with a clear background. The code I use to slide the UIView is:
- (IBAction)slideUp {
// Slide the view up the screen to reveal the next section
CGRect frame = self.view.frame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.75];
frame.origin.y = -480;
self.view.frame = frame;
[UIView commitAnimations];
}
All of the objects in the really tall UIView slide up fine, I'm just losing my background color. Any idea why?
Thanks!
Is your background being rendered by some sort of "background view" that's sized to fit the screen?
In any case, you should probably use a UIScrollView with scrolling disabled instead of a really long UIView. You can then simply animate the contentOffset property to scroll the controls up, but the scrollview itself can simply be screen-sized.
Instead of using self.view.frame, i would highly recommend you create an IBOutlet for the really long view so that the code looks like self.longView.frame.
This will help making it clear which views you are working with.
Right now i am betting that you are animating the wrong view.
THe HIG makes a statement that on the iPad, to consider fading away controls similar to how the built in photo app does it.
How is this accomplished?
In my case I have an image occupying the majority of the screen with a tab bar and potentially tool bar and potentially other controls. How do I fade everything away except the image. And bring it back if the user touches the screen.
Thanks
I think you have 2 alternatives. First, by core animation, you can set the alpha to 0 in about 0.5 or 1 second, the other way is to set the toolbar and navigation bar to hidden. If you're working with a navigation controller, you can call
[self.navigationController setToolbarHidden:YES animated:YES];
or
[self.navigationController setNavigationBarHidden:YES animated:YES];
this probably do what you want.
"And bring it back if the user touches the screen."
For this, you may implement methods like:
– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:
this will work if you're working on a UIViewController subclass only.
Good question. There are a number ways to do this as some view controllers may have built-in methods for hiding (e.g. UINavigationController). For anything that is a UIView, or subclass of, I would recommend something like the following:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
//Fade out a UIImageView over a one-second duration
imageView.alpha = 0.0;
//Fade out the TabBar, assuming it's owned by the app delegate
appDelegate.myTabBar.tabBar.alpha = 0.0;
[UIView commitAnimations];
Hope this addresses your question.
Andrew
In Apple's official Maps app for the iPhone, there is a small 'page curl' button in the lower-right corner. When you press it, the map itself peels back to reveal some options. I would like to duplicate this effect in my own app.
I'm trying to use UIModalTransitionStylePartialCurl (Added in SDK 3.2). In terms of its layout, my app resembles Apple's official Maps app almost exactly. I can easily get the ENTIRE screen to peel back, revealing another view underneath, but I don't want this. I want ONLY the map view to peel back.
In order to create this effect, you must have a UIViewController that will perform the transition. If I set this UIViewController's view to a small subview somewhere on the screen that does not take up the entire screen, I can get just that subview to peel back. That's great! However, after the second part of the transition (when the page falls back into place), the views are never where they started. Either the view that peeled back will have moved from its original position, or the view that was revealed will have expanded to take up the entire screen.
Is there any obvious mistake that I'm making? I would really appreciate any help!
The code I'm using is really simple. It's basically just:
underMapViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[curlableMapViewController presentModalViewController:underMapViewController animated:YES];
From the Documentation:
UIModalTransitionStylePartialCurl
When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views.
This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.
Although, I haven't got any exception using other presentations than full screen. I was testing out and I get the same problem as you. I found that if my ParentViewController's view is an ImageView and I set the content mode to UIViewContentModeCenter, the view is not resized or moved. Maybe there is a workaround by saving your current view as an image, put it at the top, make the curl, and after you dismiss your modal, rearrange the messed hidden stuff and remove the top image view. I know that it sounds crazy but that is what I would try if I really had to accomplish that requirement.
Hope this helps, Jorge.
How about something like this:
[UIView beginAnimations:#"PartialPageCurlEffect" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myOldSubViewController.view cache:YES];
[myOldSubViewController.view addSubview:myNewViewController.view];
[UIView commitAnimations];
Note: for some views if the views are complex and off-centre there could be artifacts. Changing cache:YES to cache:NO may fix with.
As cprcrack points out, this doesn't answer the original question. However, it's useful information, so with that in mind I'm going to leave it here.
This is actually much simpler than you'd guess.
We'll call the view controllers MapViewController and SettingsViewController. Your problem is you want to peel back part (and only part) of MapViewController to show SettingsViewController.
Here's how you do it:
Use a full size view for both views.
Only put content on the bottom half of SettingsViewController's view.
Use UIModalTransitionStylePartialCurl to transition between them, like you already are.
iOS will detect that you've done this automatically and only peel MapViewController's view back far enough to the bottom half of SettingsViewController's view, which is where all your content is.
If you put content in the top half of SettingsViewController's view, iOS will detect that and peel back MapViewControllers view all the way instead.
Summary: Put content only in the bottom half of your new view. iOS will figure it out.
(I don't think this is documented anywhere, sorry.)
I had a slight hiccough confusing
.modalTransitionStyle
and
.modalPresentationStyle
The first one goes on the TARGET viewController, e.g., the one you want underneath. The second goes on the PARENT viewController, e.g. the one that actually gets distorted by the curl. The OP got this right, but I got it wrong, and it was a frustrating 10 minutes before I figured it out. Throwing it on this post in case it gives someone else the head slap I needed.
I ran into this problem as well. For me the frame of the parent view wasn't mangled until the modal view was dismissed. So I cached the frame before dismissing then restored it right after.
CGRect frame = controllerWithModal.view.frame;
[controllerWithModal dismissModalViewControllerAnimated:YES];
controllerWithModal.view.frame = frame;
Me too had this problem,but i solved it..(dont know its the right way,but its working)
I wanted to had an imageview inside a scrollview,and when the user taps a button inside that scroll view i wanted to curl-up the scroll view and show a tableview in that place.
So i placed a tableview behind scrollview and initialy set it to hidden.when the user taps button
i did
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:frontView cache:YES];
[UIView commitAnimations];
after that removed frontview from view.
Hope that helps..
I believe that Apple's Maps application uses undocumented transitions: mapCurl and mapUncurl. I am not sure there is any way to do exactly what caecus314 wants (which is also the effect I have been trying to duplicate).
UIModalTransitionStylePartialCurl will curl up the whole bottom part of the first view, including the toolbar, which is unlike Apple's Maps app, which only curls up the map and leaves the toolbar in place.
As far as I can tell there is no way to only curl up the map.
Override the viewWillDisappear method of your underMapViewController with something like this:
- (void)viewWillDisappear:(BOOL)animated
{
curlableMapViewController.view.frame = CGRectMake(0.f, 0.f, 320.f, 416.f);
[super viewWillDisappear:animated];
}
That corrects the size of the view of the curlableMapViewController to the know size you specify, which you could save earlier in the viewWillAppear method, for example.
I have a UITabBarController in my application. In the first view of this controller I have a UINavigatioController and user can navigate to multiple views through this NavigationController. In the rootview of this controller I have my frontview or main view of the application which have an info icon, which flips the screen to info page which is an another view in my appDelegate. So I use the following code from my appdelegate to switch to info page.
UIView * controllersView = [aboutUsViewController view];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
[self.window addSubview:controllersView];
//[aboutUsViewController animateView];
[self.tabBarController.view removeFromSuperview];
[UIView commitAnimations];
My problem is when I flip, I see a very small white bar at the top. This white bar is seen only while fliping from main view that is first screen to info page and not viceversa.
I am confused how to remove this bar since I have a UIImage covering my whole page on the mainview.
How to solve this.
If the bar is only visible during a transition, then change the color of your main window to be the same as the view you are transitioning. Or you can make it totally translucent, which may do the same.
I had the same problem. I think this is a bug in the 3.1 OS. File a bug with Apple. My current workaround was to use the standard slide up modal transition. Not the best solution, but at least it doesn't look weird.
Have you tried setting wantsFullScreenLayout on your view controller?
I'm not sure if you are displaying the status bar or not, but you may want to check if your UIImage size completely goes to the top of your view - especially if you've added it in IB. Also, try setting the cache setting in your transition to NO to see if that makes a difference. It uses more resources, but I've had to do that to stop text fields from blanking out during a transition.
You probably shouldn't be doing all those animations yourself. I'm not exactly sure what your goal is, but it might be easier to use something called "pushModalViewController" and have a controller for your info page, along with a view. This may fix the problem, because it may just be something to do with animations.
Then, when you exit your info page, control returns to your navigation controller (which is what I think you want). I hope this helps.
I had the same puzzle/riddle/problem: after switching back from a modal view the underlying view had a light blue status bar, which showed for half a second:
However, because I did take this screenshot, I realized it's not the status bar, but some distant remainder of the navigation bar. I switched navigation bar off in the app delegate, but here it still, and only during the transition (after the UIModalTransitionStyleFlipHorizontal transition there was no blue bar)
Therefore what I did was giving it a translucent color:
self.title = #"";
self.navigationController.navigationBar.tintColor = [UIColor clearColor];
Might not be the world's finest solution, but it's not a bug with Apple.
If you are working on ionic2 then here is the code-
let config = {statusbarPadding: false};
ionicBootstrap(MyApp, null, config);
This worked for me!
Here it is in more details-
ionic2 how to remove white space from status bar from top in iphone