Put Random UIButtons Title of NSMutableArray to UIButtons of NSMutablearray

后端 未结 1 1342
天命终不由人
天命终不由人 2021-01-16 01:40

I have an NSMutableArray with 3 UIButtons and Second NSMutableArray with 50 UIButtons. I want to take these 3 UIButtons Titles to Assign it Character by Character to each U

相关标签:
1条回答
  • 2021-01-16 02:11

    Thanx for helping Every one ..but i done it here is code.my be it help some one others.

     - (void)getbuttontitle {
       for(int i = 0;i<[buttons count];i++)
      {
         if(i == 0)
        {
         UIButton *b1 = [buttons objectAtIndex:0];
          a = (NSString *)[[b1 titleLabel] text];
            [storewords addObject:a];
            NSLog(@"b=%@",a);
            }
        else if(i == 1)
        {
    
        }
        else if(i == 2)
        { 
    
        }
     }
    }
    
        for (NSString *str in storewords) {
            if (str==a) {
                int j = 0;
                int randn= (arc4random()%5)+1 ;
                NSLog(@"n=%d",randn);
                for (int i=randn; i<[a length]+randn; i++) {
                    NSLog(@"a=%@",a);
                    NSString *ichar  = [NSString stringWithFormat:@"%c", [a characterAtIndex:j]];
                    UIButton*  b = [saveBtn objectAtIndex:i];
                    NSLog(@"a=%@",ichar);
                    j++;
                    [b setTitle:ichar forState:UIControlStateNormal]; 
                }   
            }
    
            if (str==c) {
    
    
            }   
    
            if (str==d) {
    
            }       
        }
    
    0 讨论(0)
提交回复
热议问题