-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
imageView.image = [UIImage imageNamed:@"Sample.png"];
[self.view addSubview:imageView];
NSArray *subviews = [self.view subviews];
for(id element in subviews) {
if ([[element class] isKindOfClass:[UIImageView class]]) //check if the object is a UIImageView
{
NSLog(@"element is a UIImageView\n");
[element setCenter:CGPointMake(500., 500.)];
} else {
NSLog(@"element is NOT a UIImageView\n");
}
}
}
Я ожидал, что вывод будет "element" - это UIImageView, но на самом деле элемент НЕ является UIImageView. Почему? Это не то, что есть другие подзапросы. Есть только один. Кроме того, при запуске изображение отображается на 100 100, а не 500 500, как ожидалось.