uibarbuttonitem

Subclassing UIToolbar and overriding drawRect: - UIBarButtonItems NOT displaying

ぃ、小莉子 提交于 2019-12-13 03:09:01
问题 Context I'm using the 'initWithNavigationBarClass' method to initialize a UINavigationController with a custom toolbar, here is the line where I alloc init the UINavigationController navigationController = [[UINavigationController alloc] initWithNavigationBarClass:nil toolbarClass:[QuestionToolbar class]]; Is the class, "QuestionToolbar", I subclass UIToolbar and override drawrect, here is the drawRect method: - (void)drawRect:(CGRect)rect { [super drawRect:rect]; UIImage *backgroundImage =

UISearchBar in UINavigationBar changes width when rotating orientation

≯℡__Kan透↙ 提交于 2019-12-13 02:11:28
问题 This is driving me crazy. I am creating a splitview app on iPad. I have created a searchBar inside the UINavigationBar - something like this... UISearchBar *searchBar = [[UISearchBar alloc] initWitFrame:CGRectZero]; [searchBar setPlaceHolder:@"Search"]; [searchBar sizeToFit]; [searchBar setDelegate:self]; [self.navigatioItem setTitleView:searchBar]; this works just fine for me displaying the UISearchBar like this... I also have this UIBarButtonItem set to show Master navigation controller in

Clicked handler not executed for UIButton in UIBarButtonItem

本小妞迷上赌 提交于 2019-12-13 02:00:30
问题 I want to have a custom button title in my toolbar. This is what I've used before. UIButton someButton = UIButton.FromType (UIButtonType.System); someButton.SetTitle ("My custom button title", UIControlState.Normal); someButton.SetTitleColor(UIColor.Black, UIControlState.Normal); someButton.SizeToFit (); someBarButtonItem = new UIBarButtonItem (someButton); someButton.Clicked += someEventHandler; The Clicked event is never thrown and so my event handler is not called. I want to be able to add

UIBarButtonItem - Argument of '#selector' cannot refer to local function - Swift 3

安稳与你 提交于 2019-12-12 14:39:46
问题 I am having a problem with creating a nav button that would call handleSearch function. I receive a message Argument of '#selector' cannot refer to local function . Any help would be appreciated! override func viewDidLoad() { // various code func setupNavBarButtons() { let searchImage = UIImage(named:"search_icon") let searchBarButtonItem = UIBarButtonItem(image: searchImage, style: .plain, target: self, action: #selector(handleSearch(sender:))) navigationItem.rightBarButtonItems =

Why can't I change UIBarButtonItem's title?

情到浓时终转凉″ 提交于 2019-12-12 10:44:26
问题 I want to change UIBarButtonItem 's title . But this code is not working. - (void)viewDidLoad { ... [self smay]; } - (void)smay { ... AppDelegate *apd = (AppDelegate*)[[UIApplication sharedApplication]delegate]; NSString *SmayUse = [NSString stringWithFormat:@"%d月%d日", apd.newyear,apd.newmonth]; [_smay setTitle:SmayUse] } I don't know how to solve this problem. Please tell me a way to solve this problem. 回答1: item.title = @"new title" should work. 回答2: Initialize your UIBarButtonItem like

Changing UIBarButtonItem title impossible?

☆樱花仙子☆ 提交于 2019-12-12 10:18:45
问题 Silly thing, I am trying to change the title on a UIBarButtonItem if a certain condition in a for-loop is met. However I'm having trouble. I've tried self.barButtonItem.title=@"NewTitle" and [self.barButtonItem setTitle:@"New Title"]; I even did a setNeedsDisplay on the view afterwards without any luck. By the way, yes I am getting the old array of buttons from self.navigationBar.items, removing the old button, and setting the new one. If I change the screen orientation (flip ipad), the

UIBarButtonItem : selected / unselected an item

怎甘沉沦 提交于 2019-12-12 09:26:47
问题 I have a favorite image to display on a UIBarButtonItem , on an toolbar. How do you do to change it when this item is unselected/selected? like this screenshot: Thanks! 回答1: You can make two arrays with UIBarButtonItems: one with the first image and one with the second image. Like this: // array with unselected UIBarButtonItem *unselectedItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_unselected.png"] style:UIBarButtonItemStyleBordered target:self action:@selector

iOS: Can't minimize the keyboard after user types in TextView (xcode)

只谈情不闲聊 提交于 2019-12-12 03:02:39
问题 Another user provided me with the following code in order to make a mini toolbar above the keyboard when a user is typing in a specific TextView. All I need is a little "close" button to minimize the keyboard when the user is finished, so he/she can continue manipulating the app. -(void)viewDidLoad { [super viewDidLoad] UIToolbar *inputAccessoryView = [[UIToolbar alloc]init]; // Create one input accessory view, tool bar will be easy for you inputAccessoryView.frame = CGRectMake(0,self.view

how can I set the tint color of right UIBarButtonItem in Swift?

淺唱寂寞╮ 提交于 2019-12-12 01:46:13
问题 I'm adding a right bar button to my navigation controller with the following code in viewDidLoad : var b = UIBarButtonItem( image: UIImage(named: "settings"), style: .plain, target: self, action: #selector(sayHello(sender:)) ) self.navigationItem.rightBarButtonItem = b my settings png file is white, but when I run the app, I see it in default blue color. Anyway, I want to change it to red. How can I do it? I tried this: let navigationBarAppearnce = UINavigationBar.appearance()

UIBarButton won't show up on Table View within Tab Controller

人盡茶涼 提交于 2019-12-11 23:17:07
问题 noob question regarding ios development. In a previous project, I have a UITableViewController, to which I am adding a button in the viewDidLoad method, like this: UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(addMeasurement:)]; self.navigationItem.rightBarButtonItem = button; [button release]; This works great. I now have another application in which I am trying to do the same thing, except now I have