uibarbuttonitem

Auto Layout iOS 11 Toolbar UIBarButtonItem with customView

夙愿已清 提交于 2020-01-23 03:11:07
问题 Recently in our project there was a problem with a UIBarButtonItem that was using a customView. Before iOS 11 we did the layout via flexible spacing items. This didn't work anymore and so nothing was displayed. Because I didn't find an answer here on SO that really solved the issue for me, I looked into it and came up with a (admittedly kind of hacky) solution I wanted to share with you. Maybe it can help you or you have some feedback. This is mixed objc and swift code, hope you don't mind.

Change UIBarbuttonItems Color

放肆的年华 提交于 2020-01-21 06:28:09
问题 How can I set UIBarButtonItem's color to green? I'm using iOS 4 , there is no tint property. please help me. 回答1: In iOS 4: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal]; button.frame=CGRectMake(0.0, 100.0, 60.0, 30.0); [button setTitle:@"Green" forState:UIControlStateNormal]; [button addTarget:self action:@selector(yourAction) forControlEvents:UIControlEventTouchUpInside];

UITableView setEditing to NO doesn't change barButtonItem back

烂漫一生 提交于 2020-01-16 00:41:13
问题 I have a UITableViewController inside of a UINavigationController . I am setting the rightBarButtonItem to the editing button: self.navigationItem.rightBarButtonItem = self.editButtonItem; This works great, and after I call tableView:commitEditingStyle:forRowAtIndexPath: I programmatically change my tableView out of editing mode using: [self.tableView setEditing:NO animated:YES]; The strange thing here is, the barButtonItem still seems to be in "edit mode" as it still says "Done" like it does

Setting border around custom UIBarButtonItem

ⅰ亾dé卋堺 提交于 2020-01-15 09:16:07
问题 I want to put a custom button as right navigation bar button item. Here is the code: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"my.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(filterResult) forControlEvents:UIControlEventTouchUpInside]; [button setFrame:CGRectMake(0, 0, 50, 50)]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease]; The problem is

how can i disable user touch of a UIbarbutton without disabling?

和自甴很熟 提交于 2020-01-14 09:05:21
问题 i have a UiBarButton item in my Toolbar.i need to deactivate the user touch interaction in UiBarButton. there is no setUserInteractionEnabled property to it. when i am hiding it there is no proper visibility .can any one tell me that how can i disable user touch interaction of a UIbarbutton without disabling it? 回答1: To have a title in a UIToolBar, add a UIBarButtonItem to your toolbar and then set its customView property to a UILabel. You can then set the text of the label and not have any

How to use BBBadgeBarButtonItem in swift

让人想犯罪 __ 提交于 2020-01-14 06:03:10
问题 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 file says, I am getting an error at import line " Expected Identifier at import declaration " 回答1: You need what's called an Objective-C bridging header since BBBadgeBarButtonItem is written in Objective-C and your project is Swift. See http://www.learnswiftonline.com/getting

How to make iOS UIToolbar with back/forward arrows on the left

烂漫一生 提交于 2020-01-13 18:38:47
问题 I am trying to place a toolbar above a date picker that has back and forward arrows on the left side of the toolbar. I'd like to do this using standard iOS machinery and not roll out custom buttons to do this. Is this possible? I have attached an image for referral. Thanks in advance! 回答1: I know you don't want to use custom buttons, and this solution doesn't have custom buttons, but it does have custom icons. I hope it works for you. I have looked all over the place for a solution and did

How to make iOS UIToolbar with back/forward arrows on the left

偶尔善良 提交于 2020-01-13 18:38:26
问题 I am trying to place a toolbar above a date picker that has back and forward arrows on the left side of the toolbar. I'd like to do this using standard iOS machinery and not roll out custom buttons to do this. Is this possible? I have attached an image for referral. Thanks in advance! 回答1: I know you don't want to use custom buttons, and this solution doesn't have custom buttons, but it does have custom icons. I hope it works for you. I have looked all over the place for a solution and did

Adding a Right “done” Button (UIBarButtonItem) to a UINavigationController

佐手、 提交于 2020-01-12 07:57:05
问题 I see that a similar question was asked here: How to add a right button to a UINavigationController? (among others) but its not quite what I'm looking to do and they arent solving my problem. Essentially, I've created a UIViewController called WebViewViewController with a UIWebView on it which will be shown using presentModalViewController. Essentially its a mini web browser to display a web page while keeping the user in the app rather than launching Safari. The viewController does the

Can I use a UIBarButtonSystemItem for a UIButton?

落爺英雄遲暮 提交于 2020-01-11 08:34:09
问题 I am trying to customize a UIButton and I want to use a UIBarButtonSystemItem style that is available for a UIBarButtonItem object. How do I use a UIBarButtonSystemItem style on a UIBUtton object? 回答1: You can't. UIBarButton and UIButton are two completely different classes. The best you can do is find images close to what you're looking for and add them to UIButtons. 回答2: Use a UIView instead of a UIButton that contains a UIToolbar with UIBarButtonItems. UIView *buttonContainer = [[UIView