Customized tabBar will light up at the same time when clicking on different pages_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:52:36
Original
1032 people have browsed it

Let me explain this bug first:

When I customized the tabBar, I used 4 buttons instead. The buttons set the clicked and unclicked pictures, and then when switching to different pages, it should be Only one of them clicked, but mine would have multiple or even all of them clicked. It took me a long time to figure out where the problem was.

for (int i=0; i<4; i ) {

//Write the button’s direct parent control bottomBg here and then look for the tag, otherwise it will appear Problem

UIButton * button = (UIButton *)[bottomBg viewWithTag:100 i];

//UIButton * button = (UIButton *)[self.view viewWithTag :100 i];


button.selected = NO;

}

btn.selected = YES;

self.selectedIndex = btn .tag-100;


As shown in the code above, the problem lies in finding the button based on the tag value. It turns out that I was looking for it from self.view, and the button is on bottomBg, and bottomBg is on On self.view, I thought there was no problem if I looked for it directly, but it really didn't work.

So in the future, if you find the control through the tag value, it is best to find it directly from the parent control, and there will be no problem. I don’t know the specific reason why. I don’t know the very specific reason. Anyone who knows can give some guidance~


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template