【发布时间】:2011-11-16 00:47:44
【问题描述】:
我需要更改 UISwitch 上的文本,为此我尝试了下面的代码,
((UILabel *)[[[[[[_agreeAgb subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).text = @"Foo";
((UILabel *)[[[[[[_agreeAgb subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).text = @"Bar";
但它在objectAtIndex 崩溃了
除了制作自定义 UISwitch 之外,还有其他方法吗?
【问题讨论】:
-
永远不要使用这种黑客技术来修改内置的 UIControls。将来,如果在 iOS 的后续更新中控件的实现发生变化,它们可能会停止工作。
-
还有其他方法吗?
-
我已将其作为答案发布在下面。