English 中文(简体)
UIT View 中自定义用户界面按钮在按下后保持突出显示
原标题:Custom UIButton inside a UITableView keeps highlighted after being pressed

我已实施自定义UI按钮, 张贴在可可控制器. com上:

http://cocoacontrols.com/platforms/ios/controls/imageless-gradient- buttons" rel=“no follows” >http://cocoacontrols.com/platforms/ios/controls/imageless-gradient- buttons

我刚刚将项目转换为 ARC, 并设置了按钮。 它们起作用了, 但是在按过一次后, 它们保持突出的梯度 。

为了设置它们,我刚刚改变了故事板和IBUNTLETLES的课, 我选择了我要的梯度,在OviewDed Load上。

知道有什么问题吗?

EDIT :我花更多的时间处理它,似乎问题只在UITView 上的按钮出现时才发生。如果在UIView 上,问题就会正常。

<强度 > EDIT #2 :根据NSLogs,当容器是UIVIV主计长时,按下按钮时梯度恢复到正常状态:

2012-05-26 10:53:17.950 GradientButtons[11507:f803] highlighthed
2012-05-26 10:53:18.040 GradientButtons[11507:f803] highlighthed
2012-05-26 10:53:18.140 GradientButtons[11507:f803] Normal

当容器是 UTableView 控制器时, 按钮仍保留高梯度 :

2012-05-26 10:55:20.969 GradientButtons[11507:f803] highlighthed
2012-05-26 10:55:21.069 GradientButtons[11507:f803] highlighthed

我检查过“ ContentMode” 视图, 所有按钮、 UIView 和 UITableView (“ 填充比例 ” 都是一样的。 将其改写成重画不会改变行为 。

最佳回答

用于正常/亮度梯度绘图的支票:

   if (self.state == UIControlStateHighlighted)
        gradient = self.highlightGradient;
    else
        gradient = self.normalGradient;

您需要设置断点或添加 NSLog 以查看是否在那里选择了正常的梯度。 如果没有, 下一步将是推翻普通 UI 按钮 < code> drawRect 添加国家日志。 使用它代替有色按钮来查看是否为表格设定了标准的 UIButton 行为( 例如, 您可以在单击鼠标后保持单元格的亮度) 。


基于您的日志,我发现这个问题是一个有趣的复制问题,这似乎是一个种族条件,让被突出显示的状态被困在 touchesendiate (试图单击大约一秒钟 - 状态将是 normal at touchesendied )。

-(void) setHighlighted:(BOOL)highlighted
{
    NSLog(@"setHighlighted %@", highlighted ? @"Y": @"N");
    [super setHighlighted:highlighted];
    [self setNeedsDisplay];
}
问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签