【发布时间】:2013-11-22 21:58:49
【问题描述】:
我在 Xcode - Single View 应用程序中创建了新项目。 应用程序只有两个按钮。
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setBackgroundColor:[UIColor greenColor]];
[button1 setFrame:CGRectMake(0, self.view.frame.size.height-40-100, self.view.frame.size.width, 40)];
[button1 setTitle:NSLocalizedString(@"button 1", nil) forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[self.view addSubview:button1];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 setBackgroundColor:[UIColor greenColor]];
[button2 setFrame:CGRectMake(0, self.view.frame.size.height-40, self.view.frame.size.width, 40)];
[button2 setTitle:NSLocalizedString(@"button 2", nil) forState:UIControlStateNormal];
[button2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[button2 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[self.view addSubview:button2];
当我在带有 iOS 7 的 iPhone 上运行此应用程序时,当我按下此按钮时,第二个按钮会延迟突出显示状态。在带有 iOS 6 第二个按钮的 iPhone 上完美运行。
为什么 iOS 7 上的按钮会延迟高亮?
【问题讨论】:
-
您能否展示将这些添加到视图中的方法。即整个方法。
-
我在 viewDidLoad 方法中添加了这两个按钮。这个单一视图应用程序只是测试应用程序。我想检查按钮是否会在非常简单的应用程序中延迟 - 延迟就像在我的“普通”应用程序中一样。
-
尝试删除本地化字符串然后测试
-
不幸的是按钮在有和没有 NSLocalizedString 的情况下都有延迟。
-
两个按钮在 ios 7 中都延迟突出显示还是只有一个?无论如何尝试设置 button2.adjustsImageWhenHighlighted = YES;和 button2.showsTouchWhenHighlighted = YES;
标签: ios objective-c uibutton ios7