我有scroolViewController有UIImageView和UITextView.so我们如何抓取UItextView文本和UIImage.it的图像给出错误......
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>>
所以我们如何从获取子视图中保存文本和图像字典...... ????
答案 0 :(得分:0)
要修复编译器错误,请执行以下操作:
[dictImages setValue:((UIImageView*)subview2).image forKey:@"positionY"];
既然您已经检查过它是正确的类,那么投射就可以了。
dictImages
是NSMutableDictionary
吗?