FAQ Database Discussion Community


Accessing UIBarButtonItem textfield.text using swift

ios,swift,uitextfield,uibarbuttonitem
I have a textfield in a toolbar on the bottom of my view that will be used for posting comments. @IBOutlet var commentText: UIBarButtonItem! @IBAction func commentButton(sender: AnyObject) { println(commentText.text) // dosent work } I am trying to get the textfield.text but I can't just say commentText.text because it is...

UIBarButtonItem not clickable in UIToolBar

ios,swift,uipickerview,uibarbuttonitem,uitoolbar
I have a UIPickerView and I am adding a UIToolBar with 2 UIBarButtonItems to it. var toolBar = UIToolbar() toolBar.frame.origin.y = -40 toolBar.barStyle = UIBarStyle.Default toolBar.translucent = true toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1) toolBar.sizeToFit() var doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Bordered, target: self, action: "donePicker")...

UIBarButtonItem image appears pixelated

ios,image,uibarbuttonitem
In my IOS app, I'm trying to incorporate images on UIBarButtonItems. I found some icons on IconFinder, but they appear pixelated when I specify the image using the Storyboard (I exported 22x22 pixel pngs). It appears fine in the storyboard but pixelated on my device / in the simulator: How...

UIBarButtonItem tint color not same color on device

ios,iphone,swift,uibarbuttonitem,uicolor
I have at least one UIBarButtonItem's in every UIViewController in my project, everything is in a UINavigationController and the UINavigationBar is blue and the UIBarButtonItem's should be white. In the simulator they are white... but in device they are lightgray as you can see in the pictures below: Simulator Device...

Views not being removed from Superview when Selector method called

ios,objective-c,selector,uibarbuttonitem,uitoolbar
For my app, I have a UIToolBar that appears above a UIWebView. What I'm attempting to do is remove both the tool-bar and the web-view from the superview when UIBarButtonItem in the tool-bar is clicked. I've made the tool-bar and web-view properties of my ViewController like so: @property (nonatomic, weak)...

Animate UIBarButtonItem from right in NavigationItem

ios,swift,uibarbuttonitem
I'm trying to get my UIBarButtonItem to slide in from the right into the leftBarButtonItem position. Either slides to the wrong place and then jumps when it's set as the leftBarButtonItem or isn't visible at all. This is what I'm attempting at the moment.. func createLeftBarButton() { // Get the...

Changing vertical position of UIBarButtonItem on iOS 8.2

ios,objective-c,uibarbuttonitem
Here is my navigation bar I had a problem about changing vertical position of Settings UIBarButtonItem on my navigation bar. I would like to move the button item "Settings" down Here is my code UIBarButtonItem *settingsItem = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStylePlain target:self action:nil]; self.navItem.rightBarButtonItem = settingsItem; [[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0,-10) forBarMetrics:UIBarMetricsDefault];...

UIBarButtonSystemItemPageCurl not showing, other system icon does

ios,uibarbuttonitem
I am using a custom-made toolbar (UIToolBar), which shall display some items/buttons. One of them, however, does not show up. It is there, I can click it, it responds and fires the selector, but it is invisible. This is how I build the toolbar: spacer= [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]...

Highlight UIBarButtonItem like iOS7.1 calendar - already tried setBackgroundImage

ios,ios8,calendar,uibarbuttonitem,ios7.1
I'm trying to make a UIBarButtonItem behave like the "view mode" button in the iOS 7 calendar app. When tapped it becomes highlighted and stays this way until it's tapped again. Example image (can't embed images yet, sorry) I have already tried setting the BackgroundImage property to a image with...

How do you assign an IBOutlet programmatically using Swift?

ios,swift,uinavigationcontroller,uibarbuttonitem
I added a bar button item programmatically to a view controller: override func viewDidLoad() { super.viewDidLoad() self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Menu", style: .Plain, target: nil, action: nil) } Now I want to assign that bar button item to an IBOutlet programmatically. How would I do that using Swift?...

How do I make a UIBarButtonItem be a circle and behave like a UIButton

ios,uibutton,uitabbarcontroller,uibarbuttonitem,uitabbaritem
I have a tabbar and I want to add a UIButton (giant box) on top of the center. How do I make a UIBarButtonItem do this? I want layers, rounded borders, etc.

Bar Button Item Issue

ios,xcode5,uibarbuttonitem,uinavigationitem
I have a Bar Button called SAVE when the program running its automatically displays the title of SAVE but while i edit the contents in that particular view, the title should be changed as EDIT is there any codings are available for it?

Is there a way to have custom UIBarButtonItems in a Toolbar that go against the HIG?

ios,cocoa-touch,uibarbuttonitem,uitoolbar
These are the Human Interface Guidelines for UIToolBar Icons, and Bar Button Icons. I want something that doesn't exactly follow the HIG. Basically I want a solid rounded and flat colored UIButton, with text overtop. (However, I don't want text to be apart of the image for obvious reasons). Can...

Reload navigationBar UIBarButtonItems

ios,objective-c,uitableview,uibarbuttonitem,nsnotification
I've been trying to solve this issue, but I can't figure out how. I have a UIButton to which I need to add a UILabel as a subview. I need to update this UIButton because I don't have the number I need until a method is called through an NSNotification....

Adding an array of UIBarButtonItem resulting in an Error

ios,objective-c,xcode,uinavigationcontroller,uibarbuttonitem
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isSystemItem]: unrecognized selector sent to instance 0x7fa5bbd726f0' I have followed his solution here, and apparently I am doing no flaw. What I am doing is - adding two buttons(bar buttons) on the right side of my navigation bar. UIBarButtonItem *notificationButtonItem...

action of UIBarbuttonItem not called ios

ios,uibarbuttonitem
I am trying to call the UIBarButtonItem when the back button of that controller is pressed.This is my code.I have put the initialization in viewDidLoad and viewWillAppear but the method is not being called. UIBarButtonItem *exampleButton = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:self action:(@selector(backToViewController:))]; self.navigationItem.backBarButtonItem = exampleButton; -(void)backToViewController:(UIBarButtonItem*)sender { [self.navigationController...

Change font for Edit button in navigation controller

uitableview,swift,uinavigationcontroller,uibarbuttonitem
On the left side of a navigation controller I have a button I moved in through the storyboard. I have no issues configuring that one of course, but I wanted to use the Edit button you get from uncommenting out: self.navigationItem.rightBarButtonItem = self.editButtonItem() But how can I customize the font...

UIButton – what is the default image highlight color

ios,uibutton,uibarbuttonitem,back-button,uicolor
Is there any approach how to create from some color (let's say it's [UIColor redColor]) the default highlighted shade of this color (some kind of dark red color in this case). In my case, I have a UIButton (inside of UIBarButton) and I would like to setup the titleColor for...

How to change font size of only one BarButtonItem?

ios,swift,uibarbuttonitem
I found this code in another thread, but I want to change only one button font size. if let font = UIFont(name: "AvenirNext", size: 15) { oneBarButtonItem.setTitleTextAttributes([NSFontAttributeName: font], forState: UIControlState.Normal)} So where do I have to put the code and is this correct?...

Prompting an UIAlertView to user before navigating back to the previous controller in a UINavigationController stack

ios,iphone,uinavigationcontroller,uibarbuttonitem
I'm trying to prompt a UIAlertView before navigating to the previous controller and preventing navigation if the user decides to stay on the same View Controller. Using CCTBackButtonActionHelper, the UIALertView can be easily generated but the only problem I'm facing is that it changes the color of the back button...

How to use BBBadgeBarButtonItem in swift

ios,swift,uibarbuttonitem,badge
I want badge on a BarButton and I came across BBBadgeBarButtonItem but I am not sure if this will work in swift or not. is it possible ? if yes how ? PS I am very new to iOS and swift When I try to use it like the readme...

(Swift)UIBarButtonItem in navigation bar programmatically?

ios,swift,uibarbuttonitem,navigationbar
I've been looking around for this solution for a while but haven't got any. e.g one solution is self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: .Stop, target: self, action: nil), animated: true) This code will add a button with "stop" image. Just like this, there are other solutions with "search, "refresh" etc. But what if I...

Recognizing UIBarButtoItems with UIBarButtonSystemItemCancel at runtime?

ios,ios8,uikit,uibarbuttonitem
I would like to check for the presence of a UIBarButtonItem that was initialized like this: [UIBarButtonItem initWithBarButtonSystemItem: UIBarButtonSystemItemCancel target: target action: action]; How can this be done? It's title is apparently nil and UIBarButtonItem does not expose systemItem?...

Swift: inputAccessoryView buttons are not showing

ios,xcode,swift,uibarbuttonitem,inputaccessoryview
Following is my code for adding an inputAccessoryView (with a Done button on it) to my textView: let keyboardButtonView = UIToolbar() keyboardButtonView.sizeToFit() let doneButton = UIBarButtonItem(image: nil, style: .Done, target: self, action: "closeMessageViewKeyboard") doneButton.possibleTitles = ["Done"] var toolbarButtons = NSMutableArray() toolbarButtons.addObject(doneButton) keyboardButtonView.items = toolbarButtons as [AnyObject] messageView.inputAccessoryView = keyboardButtonView The...

UIbarbuttonitem appearance leads to crash

ios,uibarbuttonitem
CommonViewController,which inherits from UINavigationController.i accomplish the following method in it. + (void)initialize{ UINavigationBar *naVcBar = [UINavigationBar appearance]; [naVcBar setBackgroundImage:[UIImage imageNamed:@"bg_nav"] forBarMetrics:UIBarMetricsDefault]; UIBarButtonItem *buttonItem = [UIBarButtonItem appearance]; NSMutableDictionary *textAttributes = [NSMutableDictionary dictionary]; [textAttributes setObject:[UIColor blackColor] forKey:UITextAttributeFont]; [buttonItem setTitleTextAttributes:textAttributes...

Can I use the default UIBarButton icons provided by Apple in other assests of my app?

ios,objective-c,xcode,uibarbuttonitem
Like in UIButton or a UIImageView etc.. If so how do I do that using the StoryBoard or in a Xib I am able to use the default icons inside UIBarButton items but cannot look them up in normal buttons . A solution using Storyboard would be really nice ...

UIBarButtonItem backButtonBackgroundImage: gets stretched

ios,objective-c,uistoryboard,uibarbuttonitem,uiappearance
I am using UIAppearance to set a custom backButtonBackgroundImage as well as hide the back button title: // Back Button Image [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"ZSSBackArrow"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -100) forBarMetrics:UIBarMetricsDefault]; This works really well, but the problem is that my arrow image get really stretched horizontally: It should...

Present UIAlertController from UIBarButtonItem

ios,iphone,uibarbuttonitem,uialertcontroller
I'm trying to show an UIAlertController from a UIBarButtonItem, just like in the web browser in the Facebook app when clicking the actions button. But haven't been successful. Been searching on Stack Overflow, Google, Github etc, but haven't found what I'm looking for. Here you can see how it looks...

Unwind does not work

ios,swift,uibarbuttonitem,unwind-segue
I'm studying Swift, I make course in DesignCode and now I'm trying to create an app to improve what I've learned. So that is what I do: I created UIViewController and perform a segue to a UITableViewController; In the UITableViewController I embedded in with navigation bar where I create a...

ActionSheet Source View BarButtonItem

ios,swift,uibarbuttonitem,uialertcontroller,uipopover
I have a bar button item in the navigation bar that when pressed, will present a UIAlertController with the style as .ActionSheet. In the iPhone it appears just the way that I want. For the iPad I know I need to add // For iPad, set the pop over bounds...

iOS: Delegate action bar button to other class

ios,objective-c,delegates,uibarbuttonitem
I have a UIViewController with a Container, and I have a UIBarButton on Navigation Bar, and I want the action of button go to the other class, the class of View1. The class for the "Embed Segue" I don´t show because it is not need. When I click the button...

Cannot add UIBarButtonItem to toolbar in UINavigationController

swift,uinavigationcontroller,uibarbuttonitem,uitoolbar
I have tried to add the UIBarButtonItem to the toolbar of UINavigationController, but it does not show any buttons and found that the _toolbar array is empty when I am doing debug. override func viewDidLoad() { var default_title = ["A","B"," C","D"] var items: NSArray = NSArray() for title in default_title...

How to remove all navigationbar back button title

ios,swift,uibarbuttonitem
When I push a UIViewController, it has some title in back button at new UIViewController, if the title has a lot of text, It does not look good in iPhone 4s So I want to remove it. If I add some code in prepareForSegue function, it is going to be...

IOS rightBarButtonItem on UINavigationController in swift

ios,swift,uibarbuttonitem,uinavigationitem
I'm trying to put a rightBarButtonItem on a second view controller of an UINavigationViewController stack. I'm creating and setting the button in viewDidLoad of the view controller that I want to show. My actual code looks like this: override func viewDidLoad() { super.viewDidLoad() menu_button_ = UIBarButtonItem(image: UIImage(named: "menu"), style: UIBarButtonItemStyle.Plain...

how to add two multiple UIBarButtonItems on right side of Navigation Bar?

ios,xcode,swift,uinavigationbar,uibarbuttonitem
I would like to have more than a single UIBarButtonItem on the right side of my UINavigationBar. How can I achieve this? An example of what I am trying are shown below - you can notice that the top right has more than one button. ...

UIBarButtonItem in navigation bar is highlighted when selected but UIBarButtonItem in toolbar is not

ios,uitableview,swift,interface-builder,uibarbuttonitem
I have a simple UITableViewController with a NavigationController as the root view controller. I have added an "Options" UIBarButtonItem to the navigation bar and a "Start" UIBarButtonItem to the toolbar, shown below: . The issue that I am experiencing is that the "Options" button will become highlighted when pressed, like...

Add Hamburger button to navigation bar

swift,uinavigationbar,uibarbuttonitem
I'm trying to add this Hamburger button as a navigation bar button in Swift. Below is the code I've tried... @IBOutlet var button: HamburgerButton! self.button.addTarget(self, action: "toggle:", forControlEvents:.TouchUpInside) self.button.transform = CGAffineTransformMakeScale(2.0, 2.0) self.navigationItem.leftBarButtonItem = button; //ERROR: HamburgerButton is not convertible to UIBarButtonItem self.navigationItem.leftBarButtonItem?.image = UIImage(named: "menu.png"); I even tried to...

Bar Button Item in Navigation Bar is not Visible - Swift

swift,uinavigationbar,uibarbuttonitem
I know thr are many questions on this topic bt none of the solutions seemed to work. I want to implement a "back button" on my present view i.e DetailViewController which when pressed will load the initial view controller. So in the navigation bar of this DetailViewController, i hv added...

Get the frame of UIBarButtonItem in Swift?

ios,swift,uibarbuttonitem,uinavigationitem
how could I get the frame of a rightbarbuttonItem in swift? I found this : UIBarButtonItem: How can I find its frame? but it says cannot convert NSString to UIView, or cannot convert NSString to String : let str : NSString = "view" //or type String let theView : UIView...