How to programmatically adda breadcrumb view to my UINavigationController App? - iphone

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.

Related

Is it ok to have multiple UIViewControllers in a UIScrollView?

(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.

Inner shadow for navigation controller in split view controller

I'm really struggling to get an inner shadow to work on an app I'm writing as I'm not sure the best way of doing it.
I have a UISplitViewController which contains a UINavigationController as the master view. What I'm after, is a drop shadow over the menu on the left (or an inner shadow inside it)
Similar to this app
I can't figure out how to get this to work and it's driving me mad. I've looked in the appearance proxy, but you can't use it on either the navigation controller or split view controller (which makes sense)
I've subclassed the navigation controller and tried drawing things in viewDidLoad and am able to add a subview to the controllers view but I can't get a shadow to work. I can't use drawRect as this app is for iOS5 and this has been removed in place of the appearance proxy.
Any help?
Thanks
OK Not to worry. I sorted it a different way.
I created a UIView subclass that draws a simply gradient the width/height that I want, and I then add that as a subview when my navigation controller loads.
Thanks anyway :)

using UINavigationBar without UINavigationController

I want a UINavigationBar at the top of my UIWebView but I want to control by hand the title, the back button, what the back button does - etc. In other words I never want to push or pop views. I just want to change the UINavigationBar contents as the user clicks around the web view.
Where I'm up to is I added the UINavigationBar to my superView and made it 44 pixels tall. How do I set the title since I have no navigationItem? How would I set a fake back button up?
I would appreciate any pointers. I realise this is quite weird what I'm doing.
Thanks :)
The answer, if anyone's interested, is in the class reference of UINavigationBar.
When you use a navigation bar as a standalone object, you are
responsible for providing its contents. Unlike other types of views,
you do not add subviews to a navigation bar directly. Instead, you use
a navigation item (an instance of the UINavigationItem class) to
specify what buttons or custom views you want displayed. A navigation
item has properties for specifying views on the left, right, and
center of the navigation bar and for specifying a custom prompt
string.
In short, use a UINavigationItem and apply it by "pushNavigationItem" on the UINavigationBar.
I created a subclass of UINavigationBar called StaticNavigationBar which I can then load with any state by putting the appropriate UINavigationItem's on it. Thanks for all your answers people.
You can have that UINavigationBar as an outlet and then you can manupulate it as you want. So you don't have to refer to somebody's navigation item. It'll be an independent (sort of) object on your view.
If you dont want the navigationbar as-is youll have to roll your own.
if youre ok with the built in animations for pushing and popping items(dont confuse with push/pop of viewcontrollers) to the bar you would then set your UINavigationBarDelegate and use its methods for controlling how things push/pop, etc.

2 UITableViewControllers vs 1 UIViewController that swaps two UITableViews

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.

UITabBarController Hide Show Bars with animation like the Photo APP

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)