동적으로 관리하려는 UIImageView의 인스턴스가 여러 개 있습니다. 나는 각각을 가변 배열로로드 한 다음 각 인스턴스의 animationImages 속성을 설정하려고합니다. 내 질문 : UIImageViews를 가변 배열에로드하고 어떻게 속성을 동적으로 설정할 수 있습니까? 는 여기에 애니메이션 객체를 생성하는 방법은 다음과 같습니다개체를로드하고 속성을 동적으로 설정하는 방법은 무엇입니까?
NSMutableArray *collection = [[NSMutableArray alloc]initWithObjects:imageView1,imageView2,...nil];
내가 속성을 설정하는 방법을 잘 모르겠어요 :
for (int i = 1; i <= 20; i++) {[myAnimation addObject:[UIImage imageNamed: [NSString stringWithFormat:@"frame-%i.png", i]]]; }
는 여기에 내가 객체 (동적이지)를 추가하는 방법은 다음과 같습니다.
for (UIImageView * xxx in collection) {
xxx.animationImages=someAnimation;
}
은, 당신이 생각하고있는 것을 바탕으로 :
for (id xxx in collection) {
xxx.animationImages=someAnimation;
}
처럼 사용
for
루프 라인 전에UIImageView *imageView = (UIImageView *) xxx;
을 추가? 그것이 당신이하는 방법입니다. –무엇을 시도 했습니까? 네, 결국 당신이 가지고있는 것과 비슷하게 보일 것입니다. 그러나 당신은 실제로 무엇을 시도 했습니까? – borrrden
다음은 내가 가지고있는 것입니다 : NSMutableArray * collection = [[NSMutableArray alloc] initWithObjects : imageView1, imageView2, imageView3, imageView4, imageView5, imageView6, imageView7, nil]; \t (컬렉션의 ID xxx) { \t \t xxx.animationImages = hopAnimation; \t} 오류 메시지 : 시맨틱 문제 : 'animationImages'속성이 'const __strong id'유형의 개체에 없습니다. 또한 MutableArray에 동적으로 이미지를로드하는 방법을 알지 못합니다. – SimonRH