5

After changing the deployment target from 7.1 to 8.2, I just got a warning telling me that UIBarButton is deprecated.

Here is the code that I use:

UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];

numberToolbar.items = [NSArray arrayWithObjects:
                       [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(nextButton)],
                       [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], nil];
self.numberOfGuestsTextField.inputAccessoryView = numberToolbar;

Is there anything that I can use instead of UIBarButtonItem

error

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Zakaria Darwish
  • 358
  • 5
  • 22

1 Answers1

16

UIBarButtonItem is not deprecated - UIBarButtonItemStyleBordered is. Just use UIBarButtonItemStylePlain or UIBarButtonItemStyleDone instead.

As of iOS 7, the style of bar buttons has changed to a more flat form. That's why UIBarButtonItemStyleBordered is no longer available - it just looks like a UIBarButtonItemStylePlain button. With UIBarButtonItemStyleDone, the text will be bold instead of regular.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • can you take a look for my question on [stack](http://stackoverflow.com/questions/31788537/accessing-the-setmethod-of-a-property-in-ios) ?? – Zakaria Darwish Aug 05 '15 at 14:08