I am trying to recreate the behaviour in Instagram app. When a user has multiple Instagram accounts, the settings tab becomes the current users profile picture. (attached)
When a user long presses on the settings tab item it produces a pop up view to change accounts. Its important to specify that this long press gesture is triggered even if I am not on the settings tab. This makes it easy to switch accounts from anywhere in the app. Here is the attached photo
I would like to produce the same behaviour for the tab bar item. I have already created the swapping account transition. I just dont know how to add a gesture recognizer to a bar button item, can anyone help?
Related
Here is the user flow I want for my chat app:
(Basically exact same as WhatsApp, and very close to iMessage)
I have a tableVC for all existing chats inside a NavigationC. When the user clicks on the search button:
I want to have searchVC come up from bottom (it is set to present modally). If user cancels, I call dismiss(animated), which works well.
But if the user clicks on a new user to chat, I segue to chat screen using show detail, but I don't get my navigation controllers back button. How would I get it? (back to conversations not searchVC)
I don't want to embed everything in the navigationC because it doesn't really belong there. Also I looked at this answer but that does not work since I have a chatVC I want to go to. Again exact same as WhatsApp.
In images below, you can see if I click on my conversationsVC, the back button shows, but when I click on the seachVC, it disappears.
The navigationController only records viewControllers that is using show/push to perform and so it can provide back button. Otherwise, you have to embed another navigationController. Example
A perfect example of the function I want performed is when you open Google maps and click on a location and before giving you the details about where the location is, it simply pops up with a title of what you clicked. I have an image that is a map with 16 different location button pins. When a button is clicked I want a pop up with what the person clicked on (just the title), then an option to continue to the details of the location (which is on a seperate view controller).
As of now I have 16 buttons (pins) on top of an image (map) that when clicked on take you to a new view controller with the details of the location. For this I simply control dragged a button to a new view controller. How do I accomplish this?
To do what you want, don't control drag from the button to the new viewController. Instead create an #IBAction method that handles your required functionality and then, if the user chooses to click through to the details of the location, call the segue programmatically.
I have quite a complex storyboard. The first section is navigation controller based, this is for actions like sign up, reset password, setting up an account etc.
When the user is past the set up the storyboard introduces and tab bar controller which is used for the general usage of the app. I use badges to tell a user when they have a new message.
All of this works well but I have workflows where the user can change an account setting and this segues to one of the views prior to the tab bar being introduced. After they saved the setting it segues back to the tab bar section.
When the user returns back to the tab bar section of the app the badges stop working. I assume this due to the tab bar not being implemented on a view so the connection to it is lost.
I have made a pseudo storyboard image to help explain the problem. The first time the user comes though this flow the badge works (the little red circle in the image). If they stay within the tab bar section the badges continue to work. When they go from the view with the red circle to the view at the start and then back through the tab bar the badge stops working.
Is there a way to reset this so as the user segues back to the tab bar section it is just like the first time they came in?
I found the solution by setting my tab bar as a variable the first time it is used / appears and then setting the badges on the variable rather than the controller. This way as it comes through the flow a second time still works.
var rememberTabBar: UITabBarController?
then
rememberTabBar = tabBarController
and
rememberTabBar?.tabBar.items![1].badgeValue = "!";
I'm just learning iOS, and I want to create an App which will have a few buttons at the bottom of the screen.
What I'm a bit unsure about is, I know you can use a tab bar down there, but is that what you should always use when you want a button at the bottom of the screen? or there's no need to use a tab bar, and you can just put a normal button down there?
According to apple's documentation, UITabBar is a control used for displaying views.
A tab bar is a control, usually appearing across the bottom of the screen in the context of a tab bar controller, for giving the user one-tap, modal access to a set of views in an app.
If your goal with this "button" is to display other views, then you should use UITabBar component.
But if you are just searching for a "usual button", then you should use UIButton component.
A tab bar is expected to allow the user to switch between, you know, tabs; the same bar appears at the bottom of each page, and it allows you to switch between them. If that describes what you are trying to accomplish, then it would be appropriate. If your button is meant for some different purpose, then a tab bar might be misleading.
A tab bar (class UITabBar) is usually part of a tab bar controller (class UITabBarController). A button (UIButton is simply a way to respond to a tap or other actions within the button.
You want to use a tab bar and tab bar controller when you need to switch between different views and view controllers in your application. For example the Music app on your iPhone has a tab bar controller that switches between Artist, Playlist, Album, etc. These are different screens, or screens that look the same but show your music organized in a different way.
If all you want is to respond to a button, for example to print out to the console or show a message to the user that says "Hey, you've tapped the button", then a UIButton is what you need.
Also, a UIButton can have many actions, Touch Up Inside is probably the one you are looking for. This one will ensure the button has an action called if the user began a tap on the button, and let go of their finger while still on top of the button.
To summarize things:
Use a UIButton if you simply want to respond to an action, and the most common action you will connect to the button is Touch Up Inside.
Use a UITabBarController to have a way to switch between different views and view controllers.
My Application is on an iPad. I have a UIButton that I would like to mimic the action of when a user selects a phone number from a UITextField, and then selects the "Add to Contacts" button from the popover. In short, I would like that popover to appear over my UIButton when a user presses it.
I was just wondering if anyone has thought of possible ways to accomplish this, or is my only option to add contacts in iOS is to use ABUnknownPersonViewController?
You should link the button to perform a method that pushes an ABNewPersonViewController to the top of the ABPeoplePickerNavigationControler, where the user can then go and enter the data. This is what the NewPerson vc is made for.