It might be required to display a large number of images having different sizes, one by one on the screen. To make it look neat, all the images should be aligned at the center of the screen, irrespective of their size. So fixing the coordinates of the frame of the image view will not do the job. So here's the code to make sure that the images align themselves at the center of the screen, no matter if the size is big or small.
UIImageView *myImageView = [UIImageView alloc]init];
UIImage *dispImage = [UIImage imageNamed:[imageArray objectAtIndex:i]];
float w = dispImage.size.width;
float h = dispImage.size.height;
[myImageView setImage:[UIImage imageNamed:[muArray objectAtIndex:0]]];
[myImageView setFrame:CGRectMake((320-w)/2,50,w,h)];
0 Comment(s)