I'm making a app that uses a UIToolbar. My app has 8 different views and the toolbar is the same in all of them (the same buttons/images that is). The toolbar has 3 buttons. Two of them has the same (ib)action in all the views and 1 button has a specific action for each view.
My problem is that I can't get my head around how to implement it in the right way.
I tried to create and add the toolbar and the buttons in the AppDelegate. It looks right but I can't figure out how to do with the button that has a specific action for each view.
I've also tried to create and and the buttons in each view. Then it's easy to add the specific action, but it doesn't look and feel right.
This is the (ib)actions of the views, if it helps:
Button 1: popToRootViewController
Button 2: resize the current view (it's a UIWebView in all of the 8 views)
Button 3: show a overlay-view
Thanks in advance.
When showing each view, reassign the action associated to the button to be view specific
[aToolBarBtn addTarget:self action:#selector(viewSpecificAction:)
forControlEvents:UIControlEventTouchUpInside];
Related
I have a button in my app, but I have create a UIButton subclass that adds another view and a few labels on top of it. The problem is that now in my app the button does not respond to taps. How would I go about fixing this?
I was able to fix this problem by setting the view that was covering my button with the property
userInteractionEnabled = true
That allowed for the text to go through my view back to my button
Thanks for reading my question!
I have a 5-part tabbar which I use for app navigation, the center tab is covered by a UIButton and is slightly larger (much like the instagram app). This works fine.
But what I want is the far right tab bar item to show a overlaying menu when clicked. I don't want it to switch to a viewcontroller with a menu. I want the menu to be displayed no matter which of the other views you're in at the moment. So I want it to act much like a button which is in the tabbar. But I have no idea how to go about doing this.
Should I use a overlaying button over the tabbaritem or should I catch the tabbarclick, but how can I prevent the view from changing in that case?
Thanks you for any help!
You need to implement UITabBarDelegate. Then override tabBar:didSelectItem: and implement your custom displaying here. See below for reference
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITabBarDelegate_Protocol/Reference/Reference.html
Then i would just make a custom UIView and fade it in when that specific tagged UITabBarItem is pressed.
I want to put button which should be displayed on my all view.
The way we are implementing Tab Bar. I want to implement buttons.
Where should I put that button ? And where should I give its functionality ?
Create your button on main window (i.e. UIWindow) and keep front always after when you loading view.
How many views are we talking about?
If we're just talking about a few views, it probably makes sense to just include similar-looking buttons on each view. If we're talking about many views, then you'll probably want to look at other options.
One solution would be to create a subclass of UIViewController that sets up the button and contains the button's action. The controllers for each view would then be subclasses of that class, so that each inherits the button and action.
What is the best way to have the right navigation bar button flip like it does in the ipod when one changes from list view to single song view? Subclass a custom view? Are there any api's out there that already do this?
thanks
This question is similar, and discusses a few solutions. The main issue is that the UIBarButtonItem isn't a UIView, so you can't use the UIView transitions. iPhone flip right button (like iTunes)
In my iPhone application, I use a Tab Bar Controller with five items for the main navigation. However, I also need additional ways to change the current view. For example, if the user is on the Calendar tab and clicks on a date, they need to be shown a different view.
In order to implement this (and other) types of custom navigation, what do I do? I thought what I needed was to add the Navigation Controller to my Main Window nib, but this looks like it adds a navigation bar to the UI, so I don't think that's it. Basically, what is the best way to change the view when a user clicks on something like a button or item on a grid? I know how to hook these interface items to events, but don't quite get how the logic to change views goes in the Main Window nib.
Thanks!
EDIT: To clarify, I believe what I'm trying to do is navigate to a child view for that tab (not change the active tab). As Griffo commented, yes, I am trying to assemble most of the workings in IB and then tweak the code as necessary. I will be trying the approach from his attached link and reporting back.
I think this SO question answers your question
How about showing modal dialog? For instance if you have UIButton in your tab controller:
associate it with method:
[myButton addTarget:self action:#selector(onDoSomething:) forControlEvents: UIControlEventTouchUpInside];
in method -(void)onDoSomething:(id)_sender open your modal dialog:
[self presentModalViewController:mDoingsomethingController animated:YES];
implement "doing something" controller class and supply it with 'done' button and method 'onDone' containing
[self dismissModalViewControllerAnimated:YES];