I have a navigation controller that works with two UITableViewControllers. The first UITableViewController shows the user a list of their picture libraries, and when they tap a cell, the second UITableViewController gets pushed on the stack and displays the pictures in the library (much like a UIImagePicker). What I want to do is, when a user selects a photo library on the initial UITableViewController, I want the navigation title to not animate, while the transition of UITableViews does animate. Is there a way to accomplish this, or do I need to implement a UIViewController that swaps in two UITableViews (upon then I'm not sure if I'd be able to edit the back button after the second UITableView gets swapped in?).
I'm pretty sure that the easiest way would be to add two UITableViews into a UINavigationController's view and just animate them with [UIView beginAnimation] in a didselectrowatindexpath. You should also have a flag to save a view state - either a library picker view is shown to user or an image picker. Then you'll be able to handle this properly in a back button selector.
That's the easiest way IMO.
I'd recommend one UIViewController and animating the frames of the table views to transition between them.
Related
I have two subviews that load. One is a tabbar thats inside a viewcontroller which gets loaded fairly early on and the second is a view that appears when a tab bar item is pressed.
however when this subview is added it loads over the tabbar subview.. is there a way to bring to front or something along those lines?
There is a whole plethora of methods to choose from...see the section Managing the View Hierarchy in the UIView docs
(my first question here ;)
I am trying to implement the functionality that you can see in mail: where there is a up en down button to load previous or next mail.
In my case I have a UITableView with around 100 entries and if you select a row, a huge empty UIScrollView is loaded. And shown at the right offset where a DetailView is loaded. In this huge scrollview (with paging enabled) each page is the size of the screen.
The DetailView contains a UIScrollview in which the content (text) and some buttons to do stuff (mail, open link in safari etc) are displayed.
I use a (DetailView *)dequeueRecycledPage method that uses an NSSet so there are max 3 UIViewControllers alive. (current, previous, next). For fast response.
The buttons in the navbar will tell the huge scrollview to "scrollRectToVisible:animated:YES" so the user sees the new view slide in.
Right now my DetailView is subclassed from UIView, and it works. But I don't want a lot of delegation for the button actions in this DetailView. I'd rather have the DetailView handle them.
So I would like to subclass my DetailView from UIViewController.
But then we have the huge empty scrollview with 3 UIViewControllers (only 1 displayed at a time). But maybe that Apple is not keen on this, or maybe I run into trouble somehow.
So my question comes down to this:
Can a UIScrollView contain more than one UIViewControllers (only 1 displayed at a time)
Or is this "not done" or simply wrong?
thanks in advance for your help,
G
While it is theoretically possible for one UIScrollView to contains the UIViews of 3 different UIViewControllers, it is not necessarily the best practice for what you are trying to accomplish.
Typically, a better design would be to have your UIScrollView belong to a UIViewController and then you can add whatever UIViews (or subclasses there of) to your UIScrollView. Instead of creating 3 different UIViewControllers and adding their views to your UIScrollView, you could simply create 3 different UIViews and add those views to your UIScrollView.
I know you can have two (thus multiple) views within one scroll view, the company I work for has done it a couple of times.
I'm not sure what the exact code is, but you'll probably want something like:
myScrollView.addSubView(viewName).
To hide the view, do this:
if (logicToHideViewIsTrue) {
[viewName setHidden:YES];
}
More information can be found here
Generally, a UIViewController encompasses an entire screen and only one should be visible at a time. The way to implement the Mail app view involves a UINavigationController, a UIViewController and a UIScrollView.
The UIViewController should add the Up/Down buttons to the navigation toolbar.
The UIViewController has a view that should be a UIScrollView. When an Up/Down button is press, the UIViewController should receive this message and then tell the UIScrollView to change it's view to the new content.
I have a UINavigationController App. I want to add a small bar just below the UINavigationBar, around 20px height. y application is almost finished, so I want to rebuild as less code as possible. For example, if I wanted to add a button in the bottom of every view of my application, I can do that by extending UIViewController with a category, and adding a UIButton as a subview of the current controller view, maybe in the viewDidLoad method.
This approach works fine, and so I can add my UILabel to all my views at the top of them. The problem is that it does not TAKE SPACE. It is always on top of my previous views (UITableView...). What is the best way (or just one way) to accomplish such a thing without having to create for example a view with 2 frames, and having all my main views extending it?
I thought of changing UINavigationBar height, but that is definitely not an option.The prompt property of UINabivationBar is just to big (around 30px).
I also tried to create a new view in the viewWillAppear method of every UIViewController, adding to that view my breadcrumb subview, and the original view, but it is not working.
Any ideas on this?
Thank you!
If I were you, I'd make a new UIView subclass to represent this thing, and embed it on the views of the individual UIViewControllers. They can get at the navigation stack by looking at the UINavigationController's .navigationControllers array, walk that and get view titles, etc.
I'd like to display some small tutorial dialogs on top of my exiting views. I want to be able to see my existing views behind these smaller views.
Do I have to use view controllers in the same I way I would me normal views, and presentmodalviewcontroller etc ?
I haven't tried making a smaller view in interface builder before.
Also, say I want to move to another one of my existing views, full screen, while in my tutorial view. How would I close my tutorial view move to the next full screen view and launch another tutorial view ?
Example code or pseudo code would be welcome.
If your tutorial dialogs are just text, you could use UIAlertView to show the information to the user, so they can just read it and click the OK button when they're done. It's a very easy way to show some text to the user.
If you need to include images or other interactive items in your tutorial dialogs, the easiest way might be for you to just have your fullscreen view's view controller create a new view and put it up. So in this case, you'd create your view in Interface Builder, and when you want to show it, instantiate it using -[UIBundle loadNibNamed:owner:options:] and add it as a subview of your main view. Of course, it may even be easier to create the tutorial view programmatically from your view controller rather than using a nib for them at all.
Regarding the question of moving on to another fullscreen view, you would probably want to look into embedding your view controllers in a UINavigationController. This would allow you to push from the first controller to the second very easily, and the user would be able to just tap the Back button to get back to the first. If you're not looking for a navigation bar type of interface, you could present the second view controller as a modal view controller by calling -[UIViewController presentModalViewController:animated:] on your main view controller. This will pop up the second view controller fullscreen, and the user can dismiss it when they're done. Check out Apple's great documentation on UINavigationController to get a feel for how to use that:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/NavigationControllers/NavigationControllers.html%23//apple_ref/doc/uid/TP40007457-CH103-SW1
I would think that you could use existing UIViewController and simply add a new UIView that is of desired dimensions, that sits in front of other views and which is non-opaque and has alpha less than 1.
If you want a general purpose tutorial mechanism that can be placed atop any one of many UIViewControllers, then you would want to extract the navigation logic, etc.
Sorry, no code - just a few quick thoughts.
i'm having a real trouble with UITabBarController. I have a simple foto app, and I'm trying to simulate almost the same behaviour as the PhotoApp from the Iphone
the main view controler is the tabbar itself, i also have a NavBar and a status bar on top.
What i want is on tap to hide the bars (not with timer, just on tap).
The photo is actually an UIScroll view that zooms the photo or makes it again 1:1. that part already works,
I've tried before pushing the view to the navbar to set the hidesBottomBarWhenPushed and well it works, but i can't set a custom animation, and that's not the real problem , I can't show again the bars, they dissapear and i don't know how to reshow them, i'm sure i'm probably missing someting very obvious, but as my experience in obj C is little like half a year part time, i thought i asked here as stackoverflow seems to get the answers :)
Something to investigate: the Three20 project: http://github.com/facebook/three20 - it includes a completely clone of the photo-browsing app in component form.
But without Three20, you can't do this with a stock UINavigationController, because the UIViewController that you're using is a subview of the UINavigationController. You need to make a sibling view on another layer. To do this, make a parent UIViewController which has two subviews: your photo, and a UIToolbar. You can hide and display the UIToolbar by setting it's hidden property, and make sure it's above the photo view with [parent.view bringSubviewToFront:toolbarController] (where parent is the main UIViewController that contains both the photo view and the UIToolbar)