Custom UITabBarController - using a UIToolBar with UISegmentedcontrol as Tab Bar? - iphone

My customer wants a design-change, but I just can't figure out how to do this!
The app currently have a UITabBarController shifting between some UINavigationController's. My customer wants to use a UIToolBar with a UISegmentedControl shifting between the controllers instead.
I want to keep the UITabBarController, because that takes care of everything regarding loading and shifting views, but I want the UIToolBar to act as the UITabBar instead of the UITabBar!
I have allready figured out that I will need a custom UITabBarController and possibly a custom UIToolBar as well.
But I have absolutely no idea of where to start, so it would be great if somebody could give me a pointer as to where to start.
Top part to act as bottom part. http://files.droplr.com.s3.amazonaws.com/files/14763142/1g5g1s.Skjermbilde%202010-06-25%20kl.%2012.24.59.png
Thank you.

If I understand your requirements correctly, you want to have a UIToolbar at the bottom of the screen that has a UISegmentedControl that replaces pressing UITabBarItem's to switch between different views and view controllers? Assuming this is true I'd start with a custom UIToolbar class, say SegmentedControlToolbar that mirrors the basic behaviour of UITabBarController and UITabBar to add items to a segmented control, attach view controllers to each segment, and finally handle presses for each segmented control change to actually switch views.

Related

Mid-view UITabBarController IOS 7

I'm trying to build an iPhone app (ios 7+) that has a view very similar to the one in the attached image. If I had to guess, it looks like a UITabBar in the middle, with a customized UITableView inside each page, and an ImageView up top, all wrapped in a NavigationView? Is it possible to build this app's screen using these components, or is it a whole bunch of fancy custom stuff going on behind the scenes?
Specifically, I care about the tab bar in the middle of the view, controlling what is seen below it. Might that be a UITabBarController?
While UITabBar and UISegmentedControl are fairly similar, they are both best suited for different tasks - In this case, a UISegmentedControl is best.
It can be visually customized quite well, seen here in Apple's documentation.
Because it's a UIControl subclass unlike UITabBar, you can add targets for control events really easily, like this:
[segmentedControl addTarget:self
action:#selector(action:)
forControlEvents:UIControlEventValueChanged];
You could use a UITabBar and conform to the UITabBarDelegate to receive tab bar changes such as a different tab chosen, then change your views appropriately. A UITabBarController is a controller for managing a tab based view controller hierarchy which is not what you want because it would result in multiple view controllers on screen at a time, which is very frowned upon by apple.

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.

Show ToolBar over TabBar

In my app I would like to replace the TabBar with a ToolBar under certain conditions, similar to what happens in the Photos App when a user places it in selections mode (A toolbar with share copy, etc, buttons appear over the tab bar). How can I achieve this please?
This can be achieved by creating a new toolbar, assigning it an appropriate frame and adding it to self.tabBarController.view
I'm assuming your root view controller is a UITabBarController. Sometimes using the canned "Root" UIViewControllers is more of a hindrance than a help, especially if you want a highly custom look that does not fit into the paradigm of what the canned controllers offer. There's no reason you have to use them -- you could write your own, and do your own transition between your sub-UIViewController views onto the screen. You can use the UITabBar without the UITabBarController in your own custom UIViewController subclass, then you don't end up fighting the behavior of UITabBarController. Writing your own root ViewController can be very instructive as well -- you learn about all the things a root ViewController must do to manage the sub-ViewControllers.

How to programmatically adda breadcrumb view to my UINavigationController App?

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.

How can I simulate UISegmentedControl with custom buttons?

I'm just beginning to try out development for the iPhone. My requirement is very similar to thar provided by a UISegmentedControl except I need custom buttons instead of those in a UISegmentedControl.
Here's more detail:
I need one view controller which loads the first view having 3 custom buttons on the top. Below the buttons, I need to load different views (Views?) based on which button is tapped.
Is it possible to use IB to design just the lower part of the view talked about here? I want to use as much of IB I can here.
I don't understand why you can't use a UISegmentedControl here? If you drag a UISegmented control onto a Navigation Controller in IB it will be added as a "custom" button control that looks just like a UISegmentedControl. It's found in Apps like YouTube etc. You can then configure it to have three sections and connect up an IBOutlet/IBAction to it easily too.
Edit: Also, if you use a Navigation Controller, you can very easily use IB to design your other views, as that is how Navigation Controllers work - they load their subviews typically from other nibs. Therefore this would accomplish all you want.