uibarbuttonitem

QLPreviewController remove or add UIBarButtonItems

丶灬走出姿态 提交于 2019-11-27 08:05:00
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 possible to add custom button at the place of the print button, I still want to remove the printbutton and

How can I set size leftBarButtonItem?

一世执手 提交于 2019-11-27 07:21:20
问题 I am trying set size programmatically of left button bar item but i can't it. This is my code: let backButton = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) backButton.setBackgroundImage(UIImage(named: "hipster_pelo2.png"), for: .normal) self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton) But this is the result in iphone X with Xcode 9 and swift 3. In the image, you can see title app move it to the right because button size: Anybody know that the

Error when instantiating a UIFont in an text attributes dictionary

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 06:40:08
问题 I'm trying to set the font of the UIBarButtonItem like so: let barButton = UIBarButtonItem.appearance() barButton.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "AvenirNext", size: 15], forState: UIControlState.Normal) But it throws a compiler error saying: Cannot invoke 'init' with an argument list type '($T7, forState: UIControlState)` and I have no idea what that means. I have also tried barButton.titleTextAttributesForState(UIControlState.Normal) =[NSFontAttributeName...]` but

UIBarButtonItem changing title not working

≯℡__Kan透↙ 提交于 2019-11-27 06:35:13
问题 How can I change the title of a UIBarButtonItem? I have the following code which is called when an "edit" button is pressed on my UINavigationBar. -(void)editButtonSelected:(id)sender { NSLog(@"edit button selected!"); if(editing) { NSLog(@"notediting"); [super setEditing:NO animated:NO]; [tableView setEditing:NO animated:NO]; [tableView reloadData]; [rightButtonItem setTitle:@"Edit"]; [rightButtonItem setStyle:UIBarButtonItemStylePlain]; editing = false; } else { NSLog(@"editing"); [super

Make a UIBarButtonItem disappear using swift IOS

拟墨画扇 提交于 2019-11-27 06:33:45
问题 I have an IBOutlet that I have linked to from the storyboard @IBOutlet var creeLigueBouton: UIBarButtonItem! and I want to make it disappear if a condition is true if(condition == true) { // Make it disappear } 回答1: Do you really want to hide/show creeLigueBouton ? It is instead much easier to enable/disable your UIBarButtonItems. You would do this with a few lines: if(condition == true) { creeLigueBouton.enabled = false } else { creeLigueBouton.enabled = true } This code can even be

How to set image for bar button with swift?

寵の児 提交于 2019-11-27 06:27:26
I am trying to set an Image for bar button Item for that I have an image like: with resolution 30 * 30 but while I assign this Image to Bar button Its looks like: I have assigned image this way : and If I try this way like making an IBOutlet for the button and set Image programatically form this question and code for that is: // Outlet for bar button @IBOutlet weak var fbButton: UIBarButtonItem! // Set Image for bar button var backImg: UIImage = UIImage(named: "fb.png")! fbButton.setBackgroundImage(backImg, forState: .Normal, barMetrics: .Default) but nothing happend with this, Can anybody

How to Dismiss a Storyboard Popover

走远了吗. 提交于 2019-11-27 06:15:49
I've created a popover from a UIBarButtonItem using Xcode Storyboards (so there's no code) like this: Presenting the popover works just fine. However, I can't get the popover to disappear when I tap the UIBarButtonItem that made it appear. When the button is pressed (first time) the popover appears. When the button is pressed again (second time) the same popover appears on top of it, so now I have two popovers (or more if I continuer pressing the button). According to the iOS Human Interface Guidelines I need to make the popover appear on the first tap and disappear on the second: Ensure that

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

試著忘記壹切 提交于 2019-11-27 05:56:20
The following code works up through iOS 6: UIButton *myButton = nil; myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.bounds = CGRectMake(0,0,44,30); // setup myButton's images, etc. UIBarButtonItem *item = nil; item = [[UIBarButtonItem alloc] initWithCustomView:customButton]; This is how the button is supposed to be aligned: However, on iOS 7, the button appears to be offset from the right or left by too many pixels: How can I get my custom bar button items to be aligned properly? malex Works until iOS11! You can use negative flexible spaces and rightBarButtonItems property

How do I hide/show the right button in the Navigation Bar

末鹿安然 提交于 2019-11-27 05:14:59
问题 I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options. Unfortunately, the following doesn't work: NO GOOD: self.navigationItem.rightBarButtonItem.hidden = YES; // FOO CODE Is there a way? 回答1: Hide the button by setting the reference to nil, however if you want to restore it later, you'll need to hang onto a copy of it so you can reassign it. UIBarButtonItem *oldButton = self.navigationItem.rightBarButtonItem; [oldButton retain]; self

UIBarButtonItem with UIImage Always Tinted iOS 7

余生颓废 提交于 2019-11-27 05:09:50
问题 I'm trying to add a UIBarButtonItem containing a UIImage to a UIToolbar . The image keeps being tinted and I can't get it to show as the original colored image - all I want to do is display an image, verbatim, in a UIBarButtonItem ! I'm following the directions in the iOS 7 transition guide to set the image rendering mode to UIImageRenderingModeAlwaysOriginal . UIImage *image = [UIImage imageNamed:@"myImage.png"]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];