大家好,我已经实现了如下所示的代码。当我点击pressdeal按钮时,图像没有出现在屏幕上。我需要做什么才能使图像出现在UIImageView上?
- (void)viewDidload{
imagesarray = [[NSMutableArray alloc] initWithObjects:@"bg1.png",@"bg2.png",@"back-button.png",@"bluestar.png",nil];
imageOut = [[UIImageView alloc]init];
}
-(IBAction)pressDeal{
index=arc4random()%4;
image=[UIImage imageNamed:[imagesarray objectAtIndex:index]];
NSLog(@"**********2222************%@",imageOut);
[imageOut setImage:image];
NSLog(@"***********333***********%@",imageOut);
}
2012-03-20 16:41:34.135 pocker[1552:f803] **********2222************<UIImageView: 0x6a71000; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x6a73450>>
2012-03-20 16:41:34.179 pocker[1552:f803] ***********333***********<UIImageView: 0x6a71000; frame = (0 0; 0 0); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x6a73450>>
答案 0 :(得分:0)
您没有将图像视图添加到屏幕。在某处添加
[self.view addSubView:imageOut];
您还需要设置imageOut
视图的框架。
imageOut.frame = CGRectMake(0,0,320,460);