IOS: Set button in another cell in one cell

Source: Internet
Author: User

Scene:

sub-class cell has a button, with the selected style, click the button in the first cell, the button in cell one gets the selected style, but when clicked on the button in cell two, The button selection in cell one still exists, i.e. there are two selected buttons at the same time.
Workaround:

In a sub-class cell, define a

Static UIButton *selectedbutton;

Must be a static variable.

Then in the click Method,

-(void) Headerbuttonclickaction: (UIButton *) btn  {      selectedButton.layer.borderWidth = 0;      Btn.layer.borderWidth = 2;      Selectedbutton = btn;  }

So I can take the button that I clicked last time,

I set the border width display is selected, I can write the demo according to their own needs.


There is no need to worry about the program when the first execution of Selectedbutton is nil and nil.

IOS: Set button in another cell in one cell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.