uibarbuttonitem

Launch a Uitableview controller from UIbar buttons created dynamically

拟墨画扇 提交于 2019-11-29 18:11:12
- (void)createBarButtons { UIBarButtonItem *myCheckButton = [[UIBarButtonItem alloc] initWithTitle:@"Check Records" style:UIBarButtonItemStylePlain target:self action:@selector(checkRecordsAction)]; UIBarButtonItem *mySaveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveAction)]; [mySaveButton setTintColor:[UIColor colorWithRed:34.0/255.0 green:97.0/255.0 blue:221.0/255.0 alpha:1]]; NSArray *myButtonArray = [[NSArray alloc]initWithObjects:mySaveButton, myCheckButton,nil]; self.navigationItem.rightBarButtonItems =

Creating a UIBarButton Centered Programmatically

淺唱寂寞╮ 提交于 2019-11-29 17:34:55
I have an array of bar buttons that I normally set with something like: NSArray *leftButtonArray = [[NSArray alloc]initWithObjects: backBarButton, separator1,postBarButton, separator1, memeBarButton, separator1, pollBarButton, nil]; self.navigationItem.leftBarButtonItems = leftButtonArray; However, I want to change these buttons on the left to instead be center aligned. Anyone know how I can do that? Providing an example or using my buttons to do so would be a plus. Thanks! As I understand your problem it required to have some button to left, some on middle, and some on right with relative

UIBarButtonItem selector not working

一曲冷凌霜 提交于 2019-11-29 17:01:26
I have a MainViewController embed in a Navigation Controller, as shown below: And in MainViewController.swift, I added two UIBarButtonItem(left and right) programmatically: class MainViewController: UIViewController { let rightButton = UIBarButtonItem(title: "Right", style: .plain, target: self, action: #selector(onRightClick)) let leftButton = UIBarButtonItem(title: "Left", style: .plain, target: self, action: #selector(onLeftClick)) override func viewDidLoad() { super.viewDidLoad() navigationItem.rightBarButtonItem = rightButton navigationItem.leftBarButtonItem = leftButton } override func

iOS: Append FontAwesome icon with title in UIBarButtonItem and Button

 ̄綄美尐妖づ 提交于 2019-11-29 14:50:43
I want a UIBarButton Item like this in my NavigationBar and Normal UIButton like this I already tried using these links Question 1 Question 2 Question 3 but didn't got the output. My need is to append that FontAwesome icon with the button title text. Can anyone help in this? My code is: NSString *icon = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-folder-open"]; NSString *locationString = [NSString stringWithFormat:@"%@ %@", icon, @"Change"]; NSMutableAttributedString *astring = [[NSMutableAttributedString alloc] initWithString:locationString]; [astring addAttribute

Adding constraints to a UIBarButtonItem

爷,独闯天下 提交于 2019-11-29 14:29:06
Xcode is not allowing me to put constraints on my BarButtonItem on a ViewController in the MainStoryBoard. It's appearing too far to the left where it's unreadable as shown in the image. The image below shows where the BarButtonItem is. It's supposed to say "Item". I also looked on the preview split screen on Xcode and it looked fine for the iPhone6 but not for the iPhone 4 (it's half cut on the iPhone 4 but here its 3/4s cut). Here I'm running for the iPhone 6 and i get that. How do I add constraints in Xcode or how do I add the constraints programmatically to this BarButtonItem? Any help is

creating back arrow shaped leftBarButtonItem on UINavigationController

风格不统一 提交于 2019-11-29 13:51:43
I have a view with a navigation controller that I am showing modally and I want to add a back button that is shaped like the default left arrow buttons used in most splitViewControllers. I can create a basic button but I really want the left arrow shape - here is what i have now: /* set title and nav bar items */ self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back To Thumbnails" style:UIBarButtonItemStylePlain target:self action:@selector(backToThumbnails:)] autorelease]; I only saw 3 options for style here? Any suggestions are greatly appreciated! christo16

Setting action for back button in navigation controller

邮差的信 提交于 2019-11-29 13:46:22
I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the backbutton attribute it doesn't pay attention to them and it just pops the current view and goes back to the root: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Servers" style:UIBarButtonItemStylePlain target:self action:@selector(home)]; self.navigationItem.backBarButtonItem = backButton; As soon as I set it through the leftBarButtonItem on the navigationItem it calls my action,

UIBarButtonItem icon white when added via IB, black when added programmatically

不羁的心 提交于 2019-11-29 09:34:31
问题 When I add an icon to a UIBarButtonItem via the Interface Builder, the icon is displayed white. When I add the same icon file programmatically to another UIToolbar , the icon is displayed black. Why? UIImage *image = [UIImage imageNamed:@"icon.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:image forState:UIControlStateNormal]; rootViewController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:reloadButton] autorelease]

UIBarButtonItem not clickable on iOS 11 beta 7?

蹲街弑〆低调 提交于 2019-11-29 05:51:01
There is another question on SO about this but this has nothing to do with it because I think this has to do with a beta version of iOS 11. I have these 2 UIButton s that are grouped inside a UIView . This UIView is put inside a UIBarButtonItem and the whole thing is set as Left Bar Button Items , using Interface Builder. Each button, when clicked, show a popover, triggered by storyboard. I am testing this on an iPad 3, running iOS 9, using Xcode 8. This works wonderfully. Now I have decided to test this on my iPad Pro 9.7" that is running iOS 11 beta 7. I am using Xcode 9 beta 6. When I run

Make a custom back button for UINavigationController

余生颓废 提交于 2019-11-29 05:03:00
I'm developping an app for iOS 4.2+. I subclassed my UINavigationController to insert two UIImageView and make the navigation bar look custom. Everything is working great but I have a little problem. I created custom UIBarButtonItem and inside my view controllers i put them with : self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton]; It works too but the problem is that to make this work I need to call it from: - (void)viewDidAppear:(BOOL)animated ; So it only appears after the animation and I can see the non customized button 1 second before the