tags:

views:

105

answers:

2

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

+1  A: 

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:

(there is some tutorials around this, check this one)

this will work if you're working on a UIViewController subclass only.

Hope this helps.

Omer
I can get it to go away, but I can't get the view underneath to resize. I have a UIImageView inside a UIScrollView in a tab for UITabViewController. I wrote some code to walk up the view stack printing out its frame. Hierarchy has UIImageView, UIScrollView, UIView, then UIViewControllerWrapperView.Everyone has the correct size UNTIL it gets to UIViewControllerWrapperView. What is this thing and how do I set its size?
David
are you working with a navigation controller? or just nav bars/ toolbars?
Omer
Problem is with tab bar controller. View managed by the tab controller does not resize when the tab bar is hidden, so the area where the tab bar was remains white, undrawn. The only way I've found is to replace the whole tab controller view with a replacement view when hiding the tab bar.
David
+1  A: 

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

Andrew Little
Ok, thanks. I actually tried something like that. In my case the tab bar faded, but its space was not reclaimed. The image view that I do want visible did not cover the space where the tab bar used to be.Do I need to resize the image as part of the animation? If so, how? I presume I set the frame on the ImageView to size is to the entire screen. How do I know the frame of the entire screen?Related question, what does the option in IB when configuring the tab controller main view, "wants full screen" mean?
David