What is the delegate method called when rightBarButtonItem of UIBarButtonItem is tapped? I want to implement a specific action there.
Delegate method called for rightBarButtonItem of UIBarButtonItem
5.6k views Asked by Abhinav At
2
There are 2 answers
0
Ashvin
On
You don't need any delegate method. You can simply use the below code. This is code for simply adding a button on the right and adding an action to that button. In my case I called the method named "AddButtonMethod".
UIBarButtonItem *AddButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(AddButtonMethod:)];
self.navigationItem.rightBarButtonItem = AddButton;
Related Questions in IPHONE
- How to control the volume of an iPhone programmatically in objective-c
- my website crash on safari The site sometimes crashes and I can't recover the crash
- Postal Framework crash in iPhone but runs successfully in simulator
- Xcode 15 building failure when using iphone 15 as simulator, using ios 17
- Images uploaded via Active Storage not displaying in Active Admin or on certain devices
- Any problem with creating provisioning profile with old Iphone?
- Does anyone know how to make iPad layout the same as iPhone's? Size wise the text and overall layout get's smaller when I run the app on the iPad
- Keyboard not appearing when connecting smart card reader to iPhones with type-c port. i.e. iPhone 15/ 15 pro
- Access the list of SIM mobile numbers installed in the iPhone
- Can we produce haptics and record from microphone the haptic sound at the same time on iOS?
- SwiftUI's localized string do not load from main bundle despite using the main bundle identifier (an xcode bug?)
- Cordova iOS only app upload through transport requires WKWatchKitApp
- Amazon s3 video is not played on Iphone
- build getting failed for ios xcode build -flutter app
- "Error when Importing 'mysdk' into iOS Demo App: dyld Library not loaded: @rpath/MQTTClient.framework/MQTTClient"
Related Questions in COCOA-TOUCH
- How to get MetricKit SignPost Metrics data formulated into battery usage % for feature wise usage in iOS app?
- Clicking the right mouse button. Mac M1 (Designed for iPad)
- iOS Swift : How to detect that other apps are being use by the user or not?
- Text background color for newlines in TextKit 2
- How to build ios release bundle in flutter app?
- will my application be rejected if i use UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication
- Check number of touches in hitTest - Swift
- CallDirectory app extension runs out of memory without beginning request
- How do I properly design my own custom table cell?
- Reorder multiple items in a UICollectionView
- How can I transfer data between two files without segue?
- Deleting from the start of the UITextfield clears the whole textfield
- Error Running terminal command in Mac App
- How to get C char * string value in swift?
- TextView adds bottom padding/space when text is one line
Related Questions in DELEGATES
- What is the purpose of the keyword "by" (property delegates) when declaring a MutableState<T> with remember?
- How to dispose delegate in blazor or c#
- What is the difference between "Action<object?, EventArgs>" and "EventHandler(object? sender, EventArgs e)"?
- Function pointer on generic class delegate
- Unable to call main function in VS 2022
- Error when casting System.Action using contravariance in C#
- Multiple instances using delegates in unity c#
- View Modifier Doesn't Update @State
- initialization order with delegates and multiple view controllers is not working
- Delegate does not trigger method
- Persuading Kestrel to log my preferred handler name instead of "Wrapper"
- If I have an inline expression, will all references to that expression be the same for the lifetime of an application?
- Memory Leak caused by Roslyn, how do I contain it?
- Delegate to an instance method cannot have null 'this' discord.net
- QTreeView, how to use the enabled sibling column's background colour in disabled column in delegate paint method
Related Questions in UIBARBUTTONITEM
- UIBarButtonItem hit area (SwiftUI, but not only)
- Unable to customize my navigation bar inside the viewcontroller that is under a tabbar controller
- How to skip accessibility focus on one bar button item and keep focus on other bar button items of the toolbar
- Swift changing UINavigationBar's shadow affects its UIBarButtonItem when appearance change
- ActionSheetStringPicker header not showing properly with UIBarButtonItem
- Will using affine transform to shrink UIStepper as UIBarButtonItem disqualify my app?
- Swift - Programmatically change the barButtonSystemItem of an IBOutlet
- Changing background colour of navigationItem and barButtonItem in iOS 16.2
- How to conditionally show either a UIMenu or an alert from a UIBarButtonItem?
- Why is my animation of my UIButton in swift faded/transparent when getting highlighted?
- How to customise the UISearchBar cancel button
- Swift UIBarButtonItem stays highlited when going back to the root controller
- Navigation Bar Button Item Alignment Issue
- Set BarButtonItem (Left) as Image from URL
- UIBarButtonItem(title:image:primaryAction:menu:) for Mac Catalyst on macOS 13 (Ventura) is appearing disabled when primary action is nil
Related Questions in RIGHTBARBUTTONITEM
- navigationItem.rightBarButtonItems is not displayed on the root view controller when popToRootViewController is called
- Navigation Bar Button Item Alignment Issue
- The add button is below the navigation panel
- swift how to divide tableview into sections with add to cart working properly?
- how do you add left and right bar buttons to UIViewController in swift
- Add rightBarButtonItem on second place Swift
- How can I reset navigation bar items when coming back from popup?
- NavigationItem.rightBarButtonItem is not working
- large navigation bar with right bar button issue
- Added custom shadow to navigationBar not removing
- In iOS11 trying to add a round image as navigationItem in a NavigationBar and it is not clipping its edges
- Change barButtonSystemItem after tapping
- Unable to add barbuttonitem to navigation controller
- How to fit an image in rightbarbuttonitem
- Set Badge on Second to Right Most UIBarButtonItem in Objective-C
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
There is no predefined delegate method. You need to set the delegate/action (similar to a UIControl). For example, create the UIBarButtonItem in viewDidLoad the following way:
and implement actionForTap: in your view controller. If you already have the UIBarButtonItem you can set the target/action to those of your desired delegate method, e.g.:
As a third way, you can configure it in IB (but I'm not going there).