<small id='nwHBY'></small><noframes id='nwHBY'>

        <bdo id='nwHBY'></bdo><ul id='nwHBY'></ul>

      <i id='nwHBY'><tr id='nwHBY'><dt id='nwHBY'><q id='nwHBY'><span id='nwHBY'><b id='nwHBY'><form id='nwHBY'><ins id='nwHBY'></ins><ul id='nwHBY'></ul><sub id='nwHBY'></sub></form><legend id='nwHBY'></legend><bdo id='nwHBY'><pre id='nwHBY'><center id='nwHBY'></center></pre></bdo></b><th id='nwHBY'></th></span></q></dt></tr></i><div id='nwHBY'><tfoot id='nwHBY'></tfoot><dl id='nwHBY'><fieldset id='nwHBY'></fieldset></dl></div>
      <legend id='nwHBY'><style id='nwHBY'><dir id='nwHBY'><q id='nwHBY'></q></dir></style></legend>
    1. <tfoot id='nwHBY'></tfoot>
    2. 选定的 UIButton 在选定的 UITableViewCell 内消失

      时间:2023-07-07
          <bdo id='RFqOg'></bdo><ul id='RFqOg'></ul>
          <i id='RFqOg'><tr id='RFqOg'><dt id='RFqOg'><q id='RFqOg'><span id='RFqOg'><b id='RFqOg'><form id='RFqOg'><ins id='RFqOg'></ins><ul id='RFqOg'></ul><sub id='RFqOg'></sub></form><legend id='RFqOg'></legend><bdo id='RFqOg'><pre id='RFqOg'><center id='RFqOg'></center></pre></bdo></b><th id='RFqOg'></th></span></q></dt></tr></i><div id='RFqOg'><tfoot id='RFqOg'></tfoot><dl id='RFqOg'><fieldset id='RFqOg'></fieldset></dl></div>

                <tfoot id='RFqOg'></tfoot>
              1. <legend id='RFqOg'><style id='RFqOg'><dir id='RFqOg'><q id='RFqOg'></q></dir></style></legend>
                  <tbody id='RFqOg'></tbody>
              2. <small id='RFqOg'></small><noframes id='RFqOg'>

                本文介绍了选定的 UIButton 在选定的 UITableViewCell 内消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个表,我有它的 cellForRowAtIndexPath 委托,并且我在该方法中创建了 UITableViewCell 的实例,我将其返回.在 cellForRowAtIndexPath 的某个地方,我还将 UIButton 添加到该单元格的 cell.contentView 中.一切正常,直到我选择带有按钮的单元格.单元格将颜色更改为蓝色(没关系), uibutton 也将其颜色更改为蓝色.现在,如果我单击选定单元格内的 UIButton,它就会消失!哇,好奇怪,怎么解决?当我单击它时,我希望选定单元格内的 UIButton 保持不变.

                I have a table, I have cellForRowAtIndexPath delegate for it and I have instance of UITableViewCell being created inside that method, which I return. Somewhere in cellForRowAtIndexPath I also add UIButton to cell.contentView of that cell. It all works fine, until I select that cell with button in it. The cell changes color to blue (which is ok), uibutton changes its color to blue too. Now, if I click on that UIButton inside selected cell, it just disappears! Wow, that's weird, how do I fix it? I want UIButton inside selected cell to stay, when I click it.

                包括我的 cellForRowAtIndexPath 实现

                included my cellForRowAtIndexPath implementation

                    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
                    {
                static NSString *sectionsTableIdentifier = @" sectionsTableIdentifier ";
                    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: sectionsTableIdentifier];
                
                
                    for (UIView *view in cell.contentView.subviews)
                      [view removeFromSuperview];
                
                
                     if (cell == nil) {
                      cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero 
                                reuseIdentifier: sectionsTableIdentifier] autorelease];
                
                     }
                
                     CGRect newIconRect = CGRectMake(276, 40, 29, 29);
                      UIButton *newIcon = [[UIButton alloc] initWithFrame:newIconRect];
                      [newIcon setImage:[UIImage imageNamed:@"mynewicon.png"] forState:UIControlStateNormal];
                      [cell.contentView addSubview:newIcon];
                      [newIcon release];
                
                
                    return cell;
                
                    }
                

                推荐答案

                我在 OS 4.0 beta 上注意到了一个类似的问题,我在 UITableViewCell 中使用 setImage:forState:UIControlStateNormal 有一个 UIButton.当我在选择一行并按下另一个表视图后返回表视图时,该按钮将消失.为了克服这个问题,我也在图像上设置了图像:forState:UIControlStateHighlighted.我不确定这是否会解决您的特定问题,但它确实对我有用.我认为在 didSelectRowAtIndexPath: 中设置 button.highlighted=NO 也可以,但我没有尝试.

                I noticed a similar issue on OS 4.0 beta where I had a UIButton in a UITableViewCell with setImage:forState:UIControlStateNormal. The button would disappear when I would return to the table view after selecting a row and pushing another table view. To overcome this, I setImage:forState:UIControlStateHighlighted on the image as well. I'm not sure if this would resolve your particular issue, but it did for me. I think also setting the button.highlighted=NO in didSelectRowAtIndexPath: might have worked as well, but I didn't try it.

                这篇关于选定的 UIButton 在选定的 UITableViewCell 内消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在视图中淡入淡出 UIButton 下一篇:如何使用 Swift 3 为按钮制作摇动动画

                相关文章

                  <legend id='G9FoN'><style id='G9FoN'><dir id='G9FoN'><q id='G9FoN'></q></dir></style></legend>

                  <small id='G9FoN'></small><noframes id='G9FoN'>

                  • <bdo id='G9FoN'></bdo><ul id='G9FoN'></ul>
                1. <i id='G9FoN'><tr id='G9FoN'><dt id='G9FoN'><q id='G9FoN'><span id='G9FoN'><b id='G9FoN'><form id='G9FoN'><ins id='G9FoN'></ins><ul id='G9FoN'></ul><sub id='G9FoN'></sub></form><legend id='G9FoN'></legend><bdo id='G9FoN'><pre id='G9FoN'><center id='G9FoN'></center></pre></bdo></b><th id='G9FoN'></th></span></q></dt></tr></i><div id='G9FoN'><tfoot id='G9FoN'></tfoot><dl id='G9FoN'><fieldset id='G9FoN'></fieldset></dl></div>

                    <tfoot id='G9FoN'></tfoot>