0

我有 scoolViewController 有 UIImageView 和 UITextView.so 我们如何获取 UIImage.it 的 UItextView 文本和图像给出错误...

for(UIView *subview2 in [scroolViewController subviews])
{            
    NSLog(@"-----%@",subview2); 
    if([subview2 isKindOfClass:[UIImageView class]])
    {
        [dictImages setValue:subview2.image forKey:@"positionY"];
    }
    if(subview2 isKindOfClass:[UITextView class])
    {
        [dicText setValue:subview3.text forKey:@"text"];
    }
}

或者当我们扭动这个

for(UIView *subview2 in [scroolViewController subviews])
{            
     NSLog(@"-----%@",subview2); 
}

然后控制台给出:

-----<UITextView: 0xb8791d0; frame = (5 10; 285 340); text = ''; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0xb860a30>; contentOffset: {0, 0}>

-----<UIImageView: 0xb0c9d10; frame = (134 118; 100 100); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xb0c8600>>

那么我们如何从获取子视图中保存文本和图像字典...????

4

1 回答 1

0

要修复编译器错误,请执行以下操作:

[dictImages setValue:((UIImageView*)subview2).image forKey:@"positionY"];

既然你已经检查过它是正确的类,那么投射它就可以了。

dictImages一个NSMutableDictionary

于 2012-07-25T10:19:49.690 回答