Swift - Bar Button Item support function - ios

I have a Bar Button Item in the navigation bar of the view (Edit Button). Unlike other buttons (UIButton), I am unable to press ctrl and drag to view controller to create a function to handle it. I want when the button is pressed, a function body to execute.
How can I link them?

Just show the assistant editor
and use the document outline (the left bar that list all your view controllers and relative items) for select the bar button item, then CTRL & drag or drag with your right mouse button:
Automatically for bar button item Xcode link as action:

Make sure the button is selected (The view should darken a bit everywhere expect where the button is) and open up the Utilities area. Open the Connections inspector in utilities (an arrow pointing to the right) and under Triggered Segues drag from the circle to your code and create your action.

Related

Dragging Bar Button Item to Navigation Controller fails

I am following a tutorial on Udemy about Navigation Controllers.
The instructions are to drag a Navigation Controller onto the storyboard, and then drag and drop a Bar Button Item on the right of its navigation bar to segue to another view controller.
However, when I drag the Bar Button Item to its would-be position on the navigation bar, no drop-zone gets highlighted, and the button gets added to a random tab at the bottom of the screen.
I have tried finding references to this problem but all solutions are programmatic and given the wysiwyg nature of iOS development I would like to solve it through XCode UI.
Is there some setup I must change or is this an XCode 7 discrepancy?
Try to add a ViewController and then in Editor -> Embed in -> NavigationController. Then it should work.
I have solved my problem by dragging the Bar Button Item into the Document Outline, below Root View Controller.
This automatically creates Left Bar Button Items and Right Bar Button Items, which gives you an opportunity to drag the Item in the section of the controller you like.

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.

Create Modal View with Save/Cancel button

I'm pretty new to Xcode development (I'm using swift), and am building up my application flow in the storyboard. I'm attempting to create an "Add New" dialog in a similar style to that on the Calendar app.
In terms of structure, I have a UITableViewController that has a UINavigationItem on it (There is a UINavigationController before it in the storyboard. I have added a UIBarButtonItem with the Add Identifier, and created a Segue from it to a new UIViewController, using the "Present Modally" option to make the view appear in from the bottom.
On the "Add New" screen, I want to have a Navigation Bar at the top, with a Cancel Button, a Save Button and the page title (the same way the Calendar App Add Event view works).
Initially I figured I would just throw a UIToolBar item onto the page and create those items by hand. However, the apple standards seem to indicate that Toolbars should only ever appear at the bottom of the screen, not the top.
I can change the Segue to "Show", this causes the view to slide in from the right. It also sets the left hand button to a "Back" action (i.e. "
What is the apple-approved structure I should be using to do this? To summarise, I want to do the following:
Segue from the Add button on the List View to the Add View.
Animate the Add View in from the bottom
Display a Navigation Bar on the Add View containing three items:
Cancel (Far Left) - Returns to the Previous View (by sliding the view down)
Title (Middle)
Save (Far Right) - Performs a custom action (I can handle this myself)
You should present the "Add New" dialog inside another UINavigationController, even if you don't intent to push additional view controllers onto it once it is presented. This allows you to easily use navigation items again to show the buttons.

button on navigation bar is invisible but clickable

I have a button that has a custom view that I share between several view controllers for a rightbarbutton item on the navigationitem. Sometimes the button doesn't appear, but is clickable. This button is created programmatically (not in IB).
In one case where I pop the view controller that it is invisible on (by clicking the back button) and then push it again (by putting the button that creates it), then the button shows up again.

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

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.

Resources