Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between UIBarButtonItem properties

What's the difference between:

myBarButtonItem.enabled = NO;

and

myBarButtonItem.userInteractionEnabled = NO;

Does the button become gray each time?

like image 462
albianto Avatar asked Jun 13 '11 05:06

albianto


People also ask

What is UIBarButtonItem?

A specialized button for placement on a toolbar, navigation bar, or shortcuts bar. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+

What is Uiimage?

An object that manages image data in your app.

How do I change the size of my UIBarButtonItem?

You can set the font size for a specific BarButtonItem by overriding its ContentTemplate. Put an AccessText to this template and set its FontSize property. If you want to change the font size for all items in a specific BarManager, use the attached TextBlock. FontSize property.

How do I hide UIBarButtonItem?

There is no way to "hide" a UIBarButtonItem you must remove it from the superView and add it back when you want to display it again. This is actually not true - the method described by Max works well.


1 Answers

From the apple documentation uibarbuttonitem does not posses userInteractionEnabled property.Since it inherits from UIBarItem Class Reference it also does not have userInteractionEnabled property.

And also if you use this line myBarButtonItem.userInteractionEnabled = NO; your app will crash.

If you dont want your button to get pressed use this:-myBarButtonItem.enabled = NO; Also see apple documentation.

For the regular Button:-

myButton.userInteractionEnabled = NO; will cause no effect in your image image and you can not press it also.

myButton.enabled = NO; will cause the shadow to come on your button image and you can not press it also.

like image 72
Gypsa Avatar answered Nov 05 '22 09:11

Gypsa