如何在objective-c中给出imageView标签

时间:2017-09-25 10:30:47

标签: ios xcode

我正在为孩子们开发一款应用程序。

 images=[[NSMutableArray alloc]initWithObjects:[UIImage imageNamed:@"Navarre-Family-Eye-Care-Navarre-Florida-Optometrist-Santa-Christmas-Toy-Safety.jpg"],[UIImage imageNamed:@"Christmas-Wallpapers-HD-Picture.jpg"],[UIImage imageNamed:@"Christmas-Wallpaper-jesus-9413550-1024-768.jpg"],[UIImage imageNamed:@"tree.jpg"],[UIImage imageNamed:@"luxury-christmas-napkins-father-christmas-1635-p.jpg"],[UIImage imageNamed:@"Navarre-Family-Eye-Care-Navarre-Florida-Optometrist-Santa-Christmas-Toy-Safety.jpg"],[UIImage imageNamed:@"Christmas-Wallpapers-HD-Picture.jpg"],[UIImage imageNamed:@"Christmas-Wallpaper-jesus-9413550-1024-768.jpg"],[UIImage imageNamed:@"tree.jpg"],[UIImage imageNamed:@"luxury-christmas-napkins-father-christmas-1635-p.jpg"], nil];

    NSString *dd=[NSString stringWithFormat:@"%@", images];
    NSLog(@"%@",dd);



    randomIndex1=arc4random() % images.count;
    selectedImage = [images objectAtIndex:randomIndex1]; //random selected image

    NSLog(@"%@",selectedImage);

    number = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10", nil];


    randomNumber = arc4random() % number.count; //random selected number
    NSLog(@"%d",randomNumber);

    for (int i = 0; i <randomNumber; i++)
    {
        NSLog(@"%@", selectedImage);

        // _img.image = selectedImage;

        //cell.img.image=selectedImage;

    }

我使用过UIView。在UIView中我放置了15个ImageViews。因为我从output.i得到了selectedImage需要将图像放在ImageView基于tag.how做

1 个答案:

答案 0 :(得分:3)

您需要为视图中的所有15个图像设置标记,例如1,2,3,4,5 ... 15

然后检查它

$GLOBALS['TL_DCA']['tl_news']['fields']['image'] = array
(
    'label'                   => &$GLOBALS['TL_LANG']['tl_news']['quoteperson_image'],
    'exclude'                 => true,
    'filter'                  => true,
    'inputType'               => 'fileTree',
    'eval'                    => array('tl_class'  => 'clr','files' => true,'fieldType' =>'checkbox',),
     'sql'                    => "blob NULL",
);

比较randomNumber = 5,然后你可以为前5个ImageView设置图像。