我一直警告UIView可能不会响应selectedSegmentIndex。我尝试了类型转换,但我无法摆脱警告。我假设我做错了。
键入强制转换的正确方法是什么,以避免警告?
- (IBAction)segmentedControlIndexChanged:(id)sender
{
switch ([[[[self.view viewWithTag:100] viewWithTag:202] viewWithTag:203] selectedSegmentIndex]) {
case 0:
// code here
break;
case 1:
// code here
break;
default:
break;
}
}
答案 0 :(得分:2)
试试这个:
switch ([ (UISegmentedControl*)[[[self.view viewWithTag:100] viewWithTag:202] viewWithTag:203] selectedSegmentIndex]) {
...