2010-01-05 7 views
1

그냥 어떻게 각 개체를 정의하는 대신이 방법으로 NSArray를 구현할 수 있습니다.iphone 코드 - NSArray를 사용하여

코드하기 :

for (loop tag condition){ 
    [parentView viewWithTag: tag].alpha = 0; 
} 

을 그래서 실제로 당신이 항목을 만든 후 :

- (void) fadeOutShuffleAnimation 
{ 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration: 0.8]; 
    [UIView setAnimationDelegate:self]; 
    juw1.alpha = 0.0; 
    juw2.alpha = 0.0; 
    juw3.alpha = 0.0; 
    juw4.alpha = 0.0; 
    ... 
    [UIView commitAnimations]; 
} 

답변

2

juw의 *이 uiviews (또는 UIView의 서브 클래스)가있는 경우 당신은 좋아하는 그들을 통해 그들에게 고유의 태그 속성과 루프를 할당 할 수 있습니다 하위 뷰로 parentView에 추가하면 항목을 저장할 필요가 없을 수도 있으므로 항상 태그를 사용하여 얻을 수 있습니다.

1

어쩌면 0

예를 들어 모든 view.subviews의 개체 및 설정 알파를 수행하십시오

for(UIView *v in self.view.subviews) { 
    if([v isKindOfObject:[UIImageView class]]) { 
     v.alpha = 0; 
    } 
} 
1
// initialize _juwArray array 
NSMutableArray *_juwArray = [NSMutableArray arrayWithCapacity:size]; 
for (NSInteger index = 0; index < size; index++) { 
    // instantiate _juw instance and add it to _juwArray 
    // assuming conformation to NSCopying/NSMutableCopying protocols 
    // or that Juw is a subclass of UIView 
    [_juwArray addObject:_juw]; 
} 

// set alpha values 
for (NSInteger index = 0; index < size; index++) { 
    [((Juw *)[_juwArray objectAtIndex:index]) setAlpha:0.0]; 
} 
관련 문제