HOW TO SET UIBUTTON STATE IN IOS

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
 696  View(s)
Ratings:
Rate this:
I have created a UIButton on our iPhone app, now I want to manually change the button state.
I read the UIButton documentation but I can't seem to find anything about manually setting a UIButton state.
Any help would be appreciated.
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to set UIButton state in iOS

    We can set UIButton state by mannually.
    use code like this:

    UIButton *myButton=[UIButton buttonWithType : UIButtonTypeCustom];
    if(myButton isselected])
    {
        myButton.selected=FALSE;
    }
    else
    {
        myButton.selected=TRUE;
    }
    Now, we can do operation on UIButton as requirement, like executing some action when button is selected and while not selected.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!