iphone - 类型转换 UIView 警告

标签 iphone objective-c ios casting

我不断收到 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;
    }
}

最佳答案

试试这个:

switch ([ (UISegmentedControl*)[[[self.view viewWithTag:100] viewWithTag:202] viewWithTag:203] selectedSegmentIndex]) {
...

关于iphone - 类型转换 UIView 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10402789/

相关文章:

iphone - iOS : Resubmit the rejected app after fixing issue

iphone - 如何将带有 CAEmitterLayer 的 UIView 添加到我的游戏中?

ios - 如何针对特定目标文件大小优化图像大小?

ios - NSURLConnection 后的字符串变化

iphone - 如何在 iPhone 中对 NSMutableArray 值 Aa-Zz 进行排序?

iphone - 从 NavigationController 推送时如何全屏绘制 UIViewController?

iphone - iPhone模拟器崩溃?

iphone - 将铃声分配给 iPhone 中的联系人或联系人组

iOS 编辑按钮实现

objective-c - 从 NSData 转换的 NSString 中删除 unicode 和反斜杠转义