uibarbuttonitem

Changing back button in iOS 7 disables swipe to navigate back

╄→гoц情女王★ 提交于 2019-11-26 15:37:45
I have an iOS 7 app where I am setting a custom back button like this: UIImage *backButtonImage = [UIImage imageNamed:@"back-button"]; UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton setImage:backButtonImage forState:UIControlStateNormal]; backButton.frame = CGRectMake(0, 0, 20, 20); [backButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; viewController.navigationItem.leftBarButtonItem = backBarButtonItem; But this

Xcode 6 Storyboard Unwind Segue with Swift Not Connecting to Exit

纵饮孤独 提交于 2019-11-26 15:22:50
问题 When trying to connect a Navigation Bar Button to the Exit item of a ViewController in Xcode 6 (not really sure if it's an Xcode 6 problem but worth mentioning as it is in beta) it does not find the Swift function in the custom class. The function it should be finding: @IBAction func unwindToList(segue: UIStoryboardSegue) { } I made another button on the view just to make sure I could get an IBAction working with Swift and that I was writing it correctly. This works fine: @IBAction func test

QLPreviewController remove or add UIBarButtonItems

大憨熊 提交于 2019-11-26 14:03:24
问题 I have seen this kind of question a lot on the internet but it seems no one really knows the answer? I am using QLPreviewController for displaying PDF documents. I first used a UIWebView but I was recommended to use QLPreviewController instead for performance reasons with bigger documents. what I want is 4 custom UIBarButtonItem's in the top right (so where the print button is). I managed to get a custom toolbar at the bottom, but that's not really what I want. Considering that it is not

How big should a UIBarButtonItem image be?

橙三吉。 提交于 2019-11-26 12:35:21
问题 I\'m looking to create my own custom Sort By Date and Sort By Number buttons that I plan on placing in the navigation bar as the right button. How big should my image be to appropriately fill the space -- the UIBarItem documentation page doesn\'t list anything about the size the image should be. 回答1: As of iOS 11, the Human Interface Guidelines suggest glyphs be about 25×25 points in toolbars and navigation bars, up to a maximum of about 28 points. (And the HIG should definitely be in your

How can I have a UIBarButtonItem with both image and text?

允我心安 提交于 2019-11-26 09:36:16
问题 When I try to use an image for a UIBarButtonItem, the text isn\'t shown. Is there a way to show both the text and the image? 回答1: You can init the UIBarButtonItem with a custom view that has both image and text. Here's a sample that uses a UIButton. UIImage *chatImage = [UIImage imageNamed:@"08-chat.png"]; UIButton *chatButton = [UIButton buttonWithType:UIButtonTypeCustom]; [chatButton setBackgroundImage:chatImage forState:UIControlStateNormal]; [chatButton setTitle:@"Chat" forState

Change position of UIBarButtonItem in UINavigationBar

筅森魡賤 提交于 2019-11-26 08:58:11
问题 How can I change the position of a UIBarButtonItem in a UINavigationBar? I would like my button to be about 5px higher than its normal position. 回答1: There is no particularly good way to do this. Your best bet if you really must is to subclass UINavigationBar, and override layoutSubviews to call [super layoutSubviews] and then find and reposition the button's view. 回答2: This code creates a back button for UINavigationBar with image background and custom position. The trick is to create an

Adding a UILabel to a UIToolbar

一世执手 提交于 2019-11-26 06:57:40
问题 I\'m trying to add a label to my toolbar. Button works great, however when I add the label object, it crashes. Any ideas? UIBarButtonItem *setDateRangeButton = [[UIBarButtonItem alloc] initWithTitle:@\"Set date range\" style:UIBarButtonItemStyleBordered target:self action:@selector(setDateRangeClicked:)]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 20, 20)]; label.text = @\"test\"; [toolbar setItems:[NSArray arrayWithObjects:setDateRangeButton,label, nil]]; // Add the

UIBarButtonItem in navigation bar programmatically?

亡梦爱人 提交于 2019-11-26 06:56:53
问题 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 want to add a button programmatically with the image I want? 回答1: Custom button image without setting button frame: You can use init

Removing the title text of an iOS UIBarButtonItem

最后都变了- 提交于 2019-11-26 06:04:08
问题 What I wanted to do is to remove the text from the \'Back\' button of a UIBarButtonItem , leaving only the blue chevron on the navigation bar. Keep in mind that I\'m developing for iOS 7. I\'ve tried several methods, including, but not limited to: This is the image method which I did not like (the image looked out of place): UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@\"iOS7BackButton\"] style:UIBarButtonItemStylePlain target:self action:@selector

Changing back button in iOS 7 disables swipe to navigate back

我只是一个虾纸丫 提交于 2019-11-26 05:59:25
问题 I have an iOS 7 app where I am setting a custom back button like this: UIImage *backButtonImage = [UIImage imageNamed:@\"back-button\"]; UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton setImage:backButtonImage forState:UIControlStateNormal]; backButton.frame = CGRectMake(0, 0, 20, 20); [backButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc]