uibarbuttonitem

Creating a UIBarButton Centered Programmatically

橙三吉。 提交于 2019-11-28 11:52:28
问题 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! 回答1: As I

Launch a Uitableview controller from UIbar buttons created dynamically

僤鯓⒐⒋嵵緔 提交于 2019-11-28 11:52:06
问题 - (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

UIBarButtonItem selector not working

喜欢而已 提交于 2019-11-28 11:40:42
问题 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()

How to hide a bar button item for certain users

て烟熏妆下的殇ゞ 提交于 2019-11-28 10:51:56
I have a settings bar button item (set as left bar button item). I only want to display it if the user is logged in. I thought I could use the following for anonymous users navigationItem.leftBarButtonItem = nil But then how would I show it as soon as they logged in? rakeshbs You can store a copy of the leftBarButtonItem in a strong property and update it after the users log in. var leftBarButtonItem : UIBarButtonItem! Inside viewDidLoad : self.leftBarButtonItem = UIBarButtonItem(title: "test", style: UIBarButtonItem.Style.Plain, target: nil, action: nil) In logic: if loggedIn { self

UIToolbar UIBarButtonItem with both image and title has very dim text

你离开我真会死。 提交于 2019-11-28 10:31:22
My iPhone view adds some custom buttons to its toolbar. Each button has both an image and textual title, and is created like this: UIBarButtonItem *fooButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"foo.png"] style:UIBarButtonItemStylePlain target:self action:@selector(fooButtonPressed:)]; fooButton.title=@"Foo"; The title's text displays very dim; it looks like it has an alpha of about 0.5. If I use the default UIToolBar barStyle, I can't read the text at all. When using UIBarStyleBlack I can read the text but it still looks very dim. I also tried initWithTitle, and then

Adding constraints to a UIBarButtonItem

最后都变了- 提交于 2019-11-28 08:21:20
问题 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

creating back arrow shaped leftBarButtonItem on UINavigationController

时光总嘲笑我的痴心妄想 提交于 2019-11-28 07:43:41
问题 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:)]

Add a custom selector to a UIBarButtonItem

你离开我真会死。 提交于 2019-11-28 07:38:08
I am an iOS newbie. I have a navigation bar button which when clicked should execute a function of my own. What is the best way to do that? UIBarButtonItem *doneBarButtonItem=[[UIBarButtonItem alloc] init]; doneBarButtonItem.title=@"Done"; self.navigationItem.rightBarButtonItem = doneBarButtonItem; [doneBarButtonItem release]; One way is to init with the target and action: UIBarButtonItem *buttonHello = [[UIBarButtonItem alloc] initWithTitle:@"Say Hello" style:UIBarButtonItemStyleBordered target:self action:@selector(sayHello:)]; Another way is to set the target and action after you created it

Resize UIBarButtonItem in code

爷,独闯天下 提交于 2019-11-28 07:17:37
问题 How do I resize a UIBarButtonItem in the code? 回答1: You can't resize a UIBarButtonItem as you would a UIView. What you can do is change its width property. UIBarButtonItem *b; // Initialize and such ... b.width = 150.0; This should work for a Fixed Space Bar Button Item. 回答2: If you want to use some custom image in UIBarButtonItem, you can use this code. DoneButton = [[UIBarButtonItem alloc] initWithTitle:[Settings getConfigurableLabel:GENERAL_DONE] style:UIBarButtonItemStyleBordered target

iphone - Custom UIBarButtonItem for back button

人盡茶涼 提交于 2019-11-28 06:06:11
I am trying to use a custom item for the back button in my navigation bar. UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"]; UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithImage:backButtonImage style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationItem setBackBarButtonItem: customItem]; [customItem release]; What I end up getting is my image with a border around it. It looks like this (My image is the back button): How can I get rid of the border? What am I doing wrong? Your image is appearing inside of a back button and it is apparently (from