uibarbuttonitem

How to change UIBarButtonItem's type in UINaviagationBar at runtime?

独自空忆成欢 提交于 2019-12-07 02:48:13
问题 I am working on an iPhone's view which composed 3 elements, UITextView, UIToolBar with an UIBarButtonItem. The goal is, I want UIBarButtonItem change its style from 'edit' (UIBarButtonSystemItemEdit) to 'Done' (UIBarButtonSystemItemDone) and update new selector to new method. First of all, I have tried following code but it doesn't work: Could you help me on this idea? 回答1: There is a builtin bar button with this behaviour, you get it via the editButtonItem property of a UIViewContoller.

How to set UIBarButtonItem alpha

不想你离开。 提交于 2019-12-07 02:25:37
问题 let searchBtn = UIBarButtonItem(image: UIImage(named: "ic_search"), style: .plain, target: self, action: #selector(self.searchButton)) let moreBtn = UIBarButtonItem(image: UIImage(named: "ic_more"), style: .plain, target: self, action: #selector(self.moreButton)) self.navigationItem.rightBarButtonItems = [moreBtn, searchBtn] moreBtn.alpha = 0 //something like this not working class CodeToPass: QualityStandarts { let doesnt = "meanAnything" } I have two UIBarButtonItems. Which made manually.

UIBarButtonItem created using initWithCustomView doesn't trigger action

爷,独闯天下 提交于 2019-12-07 01:00:55
问题 I'm updating some old code, and to make more room in a toolbar, I'm converting the Buttons from test to images. An example of the new and old code in loadView is this: // New code, doesn't work. UIButton *toggleKeyboardBtn = [UIButton buttonWithType:UIButtonTypeCustom]; toggleKeyboardBtn.bounds = CGRectMake( 0, 0, showKeyboardImage.size.width, showKeyboardImage.size.height ); [toggleKeyboardBtn setImage:showKeyboardImage forState:UIControlStateNormal]; UIBarButtonItem *toggleKeyboardItem = [

UIBarButtonItem + popover segue creates multiple popovers

元气小坏坏 提交于 2019-12-06 22:38:45
问题 I've currently have an iPad app with a UIToolbar containing two UIBarButtonItems, each of which is connected to a popover segue. When the user touches either of the UIBarButtonItems, the popover is created rather than toggled. This creates multiple, overlapping popovers. I've been able to close the previously created popover using the following code - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // First close the preferences popover if it's open per Apple guidelines

buttons on navigation bar not loading

倾然丶 夕夏残阳落幕 提交于 2019-12-06 16:19:28
问题 i want to add buttons on navigation bar but its not loading on bar.Please help.Following is my code.please tell me where i am going wrong.The view i am using is landscape - (void)viewDidLoad { [super viewDidLoad]; CGRect rect = CGRectMake(0.0, 0.0, 480.0, 32.0); navBar = [[UINavigationBar alloc] initWithFrame:rect]; navBar.items = self.navigationController.navigationBar.items; navBar.delegate = self; //[navBar release]; navBar.tintColor =[UIColor blackColor] UIBarButtonItem * rightButton = [

How can I make the text of a UIBarButtonItem wrap to two lines?

我与影子孤独终老i 提交于 2019-12-06 15:47:34
Some of the titles of view controllers in my UINavigationController are quite long, which makes the back button in the navigation bar of the next view controller in the hierarchy miss out some of the text, with a "..." instead. How could I make the text of the back button wrap onto two lines, as with "Now Playing" in the navigation bar of iPod.app? Thanks! You could use the UIBarButtonItem method initWithCustomView: then set the rightBarButtonItem property in UINavigatiobItem. 来源: https://stackoverflow.com/questions/2614098/how-can-i-make-the-text-of-a-uibarbuttonitem-wrap-to-two-lines

setBackgroundImage for UIBarButtonItem via appearance not working for other UIControlStates

可紊 提交于 2019-12-06 14:36:51
I'm trying to customize a UIBarButtonItem using the appearance method (>iOS 5.0). It works fine for the UIControlStateNormal, but not for highlighted or disabled. See images Here's the code I use to set those: // now configure the UIBarButtonItems UIImage *buttonBGInactive = [[UIImage imageNamed:@"button-navbar-30-inactive.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)]; UIImage *buttonBGActive = [[UIImage imageNamed:@"button-navbar-30-pressed.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)]; [[UIBarButtonItem appearanceWhenContainedIn:

Changing back button background image

三世轮回 提交于 2019-12-06 14:07:20
Using this method to change title and background image of the back navigation button. Title is changed but button stays black - (void)viewDidLoad { [super viewDidLoad]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"topBarbackground.png"] forBarMetrics:UIBarMetricsDefault]; UIBarButtonItem *backButton = [UIBarButtonItem new]; [backButton setBackgroundImage:[UIImage imageNamed:@"backButton.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [backButton setTitle:NSLocalizedString(@"Back", nil)]; [[self navigationItem] setBackBarButtonItem

Cannot set action on UIBarButtonItem

对着背影说爱祢 提交于 2019-12-06 12:29:52
问题 So I'm adding a bunch of custom UIBarButtonItems to a UIToolbar, and they all load just fine and look great, and I can see them in my UIToolbar. The only problem is, I can't perform any actions on them. In my viewDidLoad, I set up everything. Here are my .h and .m files: .h file: #import <UIKit/UIKit.h> #import <MobileCoreServices/MobileCoreServices.h> #import <QuartzCore/QuartzCore.h> @interface PhotoEditViewController : UIViewController <UIPopoverControllerDelegate,

Hiding UIBarbuttonItem of navigationcontroller swift

情到浓时终转凉″ 提交于 2019-12-06 11:31:42
问题 New to swift implemented sliding menu by learning from swrevealviewcontroller swift now i want to hide the menu button i.e. UIBarButtonItem which opens the side menu. I have searched found most of place following code: menuBtn.enabled = false but it only disables the button and not hide it. Please let me know what wrong i am doing here. 回答1: If it's the left button : self.navigationItem.leftBarButtonItem.enabled = false; 来源: https://stackoverflow.com/questions/33103482/hiding-uibarbuttonitem