-1

forステートメントにさらにステートメントを含めたい。今私はこれを行います:

for (UIImageView* img in imageArray){
for (UITextField* txt in messagename){

}}

...しかし、このようにしてコードが複数回繰り返されるので、これを試しました:

for (UIImageView* img in imageArray)||(UITextField* txt in messagename)

しかし、それは動作しません!

編集:

for (UIImageView* img in imageArray)||(UITextField* txt in messagename) {


    img.hidden = YES;

    CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    [anim setToValue:[NSNumber numberWithFloat:0.0f]];
    [anim setFromValue:[NSNumber numberWithDouble:M_PI/80]]; // rotation angle
    [anim setDuration:0.1];
    [anim setRepeatCount:NSUIntegerMax];
    [anim setAutoreverses:YES];
    //[img.layer addAnimation:anim forKey:@"iconShake"];


    UIImage *tmpImage = [UIImage imageNamed:@"message small type 2.png"];
    CGRect cellRectangle;
    cellRectangle = CGRectMake(20, img.frame.origin.y + 45, 710, 60);
    UIImageView *dragger = [[Draggable alloc] initWithFrame:cellRectangle];
    [dragger setImage:tmpImage];
    [dragger setUserInteractionEnabled:YES];

    [self.view addSubview:dragger];

    [wobbleImage addObject: dragger];

    Draggable* sharedSingleton = [Draggable sharedManagerDraggable];
    sharedSingleton.namePassedToDraggable = txt.text;

    dragger.tag = img.tag;

    dragger.layer.cornerRadius = 10; // this value vary as per your desire
    dragger.clipsToBounds = YES;

    [dragger.layer addAnimation:anim forKey:@"iconShake"];

}
4

1 に答える 1

2

両方の配列に常に同じ数のオブジェクトがある場合、おそらく必要なのは次のとおりです。

NSUInteger count = imageArray.count;
for (NSUInteger i = 0; i < count; i++) {
    UIImageView *img = imageArray[i];
    UITextField *txt = messagename[i];

    // rest of code
}
于 2012-12-14T17:17:28.387 に答える