showing a box type-view on click of a button and on click of a tab bar item - ios

In my application, i need to show a dilog-type view when a user clicks on a UIButton. I need to do the same thing when the user clicks on a tabBar item of a UITabBar
Sorry, in order to make myself clear, i had to create it in paint. Should i create a view with background image of the dilog box, and add two buttons in the view accordingly? I also need to give an alert-view like effect to the view when it is shown.
How do i implement it in a tabBarController?
On clicking on the red button, the view with black border should be shown with an alert-view type effect.

Related

Objective c - Create a tutorial bubble that will hide in background click

(First - i'm sorry about my english:).
I want to create a tutorial bubble that will pop up in some situations while using my app.
I need this popup to disappear when clicking or scrolling on every view in my VC, and i need that these buttons to do what they need to do in this click event and not only dismiss the pop up so then we will need to click on the buttons again.
I have 2 ways to do it, but every one of them have some disadvantage.
the popup view will have a transparent view with frame of the whole VC. this background view will dismiss the pop up in its touchBegin event.
but like that i can't click ob my buttons that below this popup background view.
the second option is to create the pop up without the background transparent background, so all the buttons will be clickable.
but in this situation i don't know how to listen all the buttons click event or table scroll event so i can dismiss the popup.

Add an inputview to UIButton for on click event iOS

I am building a page for a Swift iOS app and I want the user to be able to specify the date range for a graph. At the top of my graph I want the user to select a date range by clicking on a button which will gray out the screen and bring up a picker view on the bottom of the screen to select the date range. It's very similar to how the myfitnesspal app does it (below):
As you can see when they click on the calendar button it brings up a pickerview while graying out the rest of the screen and only recognizes touches to the pickerview. I basically want to replicate this kind of method that allows me to bring up a custom picker when a button is clicked.
I have tried using UIActionSheet however that is now deprecated and I've read that an action sheet should not be used for this kind of functionality.
You can do this by designing a view controller such that-
It has a background view that covers entire screen with background color as black with some alpha say 0.3. This view will serve to block out any touches on the views behind it. Basically it will have that translucent background effect.
Have your actual view such as picker view as a sibling of this, add other siblings like the cross button, etc. You can use the cross button to initiate closing of the view.
Present this controller as a child view controller on the controller where you need this.

How to set action for the bottom UIBarButtonItems in objective C?

I have an application where there are two items at the bottom bar in a view controller. One item is at the left and another one is at middle of the bottom bar. Now, what I like to do that when someone click on the middle item of the bottom bar, it will redirect the user to the website. how to get the action for the middle item of the bottom bar.
If this is a UIBarButtonItem, it has a target property and an action property, These configure what it does when tapped — it sends the action to the target. In theory, you should have configured these when you created the UIBarButtonItem.

Show an image thats hidden thats on a view controller from another view controller that has a button

I have two squares on one ViewController which are ImageViews. One is white the other black. At any time one is hidden, the other is one shown. I want to switch which one is shown based on if the user presses a Button that's either white or black and is on another ViewController. I want to show this when I press on a Button to go back to the first ViewController and either the black square is showing or white square is showing depending on which Button I selected from a Button that's on another ViewController.
You can keep track of the state of the ImageViews (on or off) in NSUserDefaults or a Singleton from the first controller when pressing the associated button. Then grab this state from the second view controller so you know what to display.

Should I use a tab bar or button at the bottom of my ViewController?

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.

Resources