I'm new to this :-(.
I have a pretty standard Tab Bar Controller to which I've added a UIButtonBarItem (I used the storyboard editor to do this). It all looks fine, but I don't know how to handle the "button press" event. I have established a delegate for the tab bar controller, so I can capture the "didSelectViewController" events (not that it seems to help :-).
I think I'm missing something obvious.
The Tab Bar Controller automatically creates buttons when you connect other views to that one. I had this same problem using storyboard editor even though you can put it in there I believe it won't allow you to use it. I think even just setting up an IBOutlet won't work.
In the docs:
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/TabBarControllers.html
Apple specifically talks about how you just create the views and the buttons are automatically handled for you.
Otherwise if you want a tab button that doesn't bring up a new view (thats what I wanted), supposedly that doesn't fit in with Apple's design principles for what a Tab controller is.
I finally stumbled across the solution:
Set up a delegate for the TabBarController ()
Create a method on the delegate to handle the action: -(IBAction) someHandler:(id) sender;
Drag a Bar Button Item into the "Navigation Bar" of the common Tab Bar Controller
Select the bar button, control-drag to the "First Responder" and select the "someHandler" method.
That's it, not that hard, should have figured it out earlier.
Related
I would like to know if someone have an idea about how Tapbots made Tweetbot3 TabBar?
In my app, there will be many TabItems, and I don't want the "More" Tab (by default), but I'm very interested to have a similar system to Tweetbot, with a "picker" which opens on long press gesture on a TabBarItem.
But, I'm hesitating on the method. It's better to apply a customized UITabBar class, or to totally "deconstruct" the UITabBarController (to use a UIViewController and a custom "tabbar")?
Having created many custom tab bars, I'd start by subclassing UITabBar and UITabBarController. I wouldn't expect any roadblocks with this approach.
You may want to move the default buttons around and then add some custom buttons. Send a message back to the tab bar controller and let it display the popup choices view.
What I mean is a static "top-bar" that I can edit from the relevant swift file.
I don't actually want any of the navigation function, but I want to be able to change what it says situationally.
I've looked around quite a bit but can't seem to find a solution for this seemingly simple task.
Thanks in advance.
I am not quite sure, if this is what you want.
However, if you want a navigation bar with customizable navigation item title/text, then you can just add Navigation Item from the Object library to your Navigation bar.
Then in the inspector, you can select custom and specify the title of that navigation item as you desire. You can also create an IBOutlet for it and change the title in your code in different situations.
Ctrl Drag the bar button from the storyboard to the appropriate view controller implementation file. I.e viewController.h. This will create an IBAction, which you can name.
- (IBAction)nameOfAction:(id)sender {
// Action goes here
}
Any logic applied inside will be called on button press.
So it was a pretty easy, but not straightforward solution...
All I had to do was
Add a navigation bar, by clicking Editor -> Embed in -> Navigation Controller
The hard to find part, use the property self.navigationItem.title = "title" to change the title.
The second part I found from hgwhittle's answer in this question, which also covers how to change the nav bar title, the tab bar title, or both.
UIViewController Title attribute in Storyboard
The title won't clear the actual problem. Let me explain clearly.
I have a tabbarcontoller in the viewcontroller which is the main view controller of the single view application project.
I added Navigationcontrollers to the tabbarcontroller. So that I can navigate(push/pop) from one viewcontroller to other.
I added a subview to the mainview of a single navigation controller.
When I click the button near to the tabbar, it doesn't get clicked and the tabbaritem button gets access and shows that tab.
The below image will explain well,
If I click the show button, it opens the receipts tab.
How to reduce the click access boundary of the tabbar in tabbarcontroller?
I can't get any solution regarding this.
Frankly, i've written a bunch of applications which have controls near the tab bar and i've never encountered such behaviour.
Check if you have custom tabbar controller with custom frame.
Also try to use Reveal App (http://revealapp.com/) to check the buttons' frame at runtime, it will help you to understand what's going on. They have trial version as i remember.
Hope it will help :)
Choose the custom button for this and add in tabbar.
I make my first "serious" iOS app, and have some troubles with the whole UINavigation concept, but all in order. I look answers for my questions but don't find what I want, so here it is.
I want to make menu to a game, it would be look like so:
1) It's a RootViewController and it contain some buttons: new game, options, about.
2) I think it will be another view controller (It must appear when we touch new game button, and we see a menu when we choose game difficulty) the buttons is: easy, medium, hard
3) The game view controller (I think that this VC won't be the part of UINavigationController).
I have some concepts that I want to embody in this menu.
Here is it: I don't want to use UINavigationController Navigation bar, I won't use standard slide animation for UINavCon, I want to make my buttons "move to transparency" and come back with another menu from paragraph 2 mentioned above, it's not necessarily to change background or something else except menu items.
I want to use custom back button, and want to add it to the position I want and not to Navigation Bar.
I have some ideas about animation of menu items.
I don't know this:
It is better to use UINavigationController for my purposes or it's better to use normal ViewController?
If I make a UINavigationController can I see it's "child VCs (I mean not a root VC)" in my storyboard or it will be programmatically created thing and I must make it UI in code? If i must do this programmatically, could I make a segue from UINavigationController from storyboard, or I must do this from code too?
Could I make a UIButton, for example, and assign it functions from a normal UINavigationController back button from Navigation Bar?
Some questions might be dumb, but hope you won't judge me hard.
Okay, I'll do my best:
For custom animations, see
Yes, you make a custom segue class with the animation. try: joris.kluivers.nl/blog/2013/01/15/… and developer.apple.com/library/ios/#featuredarticles/… and cmumobileapps.com/2011/11/04/a-short-tutorial-on-custom-segues
Yes, i think a view controller is your best bet. But by the way, even if you use a navigation controller, you still use normal view controllers. A UINavigationController holds different UIViews, which go forward and backward on the navigation stack. Also, you will need to look up what you need to do to hide the navigation controller.
You can see the child view controllers in a storyboard if you create them their, but not if they are created programmatically, unless you just have the view in their.
[self.navigationController popViewControllerAnimated:YES] will "press the back button" programmatically, so just link the custom back button to a method that calls this.
If that doesn't cover all of your questions, just comment and I'll answer any more :)
In my app I would like to have a way to make the user go to a website, but not leave my app.
I do that with a UIWebView.
I'd like to constantly have a "Back to app" button on the NavigationBar on the top.
The rest of the Web navigation (back, forward) should be on the top as well, but appear and disappear with the context.
The problem is that I don't know how to make the buttons appear on the UINavigationController.
How can this be done?
I have my UIWebViewDelegate set up to receive all the relevant functions, but the buttons don't appear.
EDIT: I need to solve this programmatically
As of iOS 5, there are leftBarButtonItems and rightBarButtonItems (note the plural) properties on UINavigationItem, so there's a way to have more buttons. It seems to me that these are only accessible programmatically, but not from Interface Builder.
If you can, my suggestion is to not just add the Web View as a subview, but to give it its own ViewController and push that on the Navigation Controller's stack. That'll give you your back button for free (that's kind of what UINavigationController was designed for, after all). And it should help you to keep the web browsing code separated form the other stuff in your app.
NB: in your case, you'll have set the leftItemsSupplementBackButton property of the Browser View Controller's navigationItem to YES to get the automatic back button (the details are in the documentation)
You can not have more than two buttons on the NavigationController's navbar without doing some tricks. There are two properties self.navigationItem.leftBarButtonItem and self.navigationItem.rightBarButtonItem. If not, add a custom view and place the buttons there. A good way to implement multiple buttons with multiple actions is shown here.