0

i have a view i added text and images on that view. i want that if i added one image then at the same time i also added next and next image, but i have problem in that. when i move one image in that specific view then the other images also there not to be disappeared.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    self.imageView.hidden =NO;

    self.imageView .image = image;

    [txtNotes addSubview:self.imageView];

    [picker dismissViewControllerAnimated:YES completion:NULL];

}

enter image description here

user4261201
  • 2,324
  • 19
  • 26
SoftCoder
  • 167
  • 1
  • 2
  • 10

2 Answers2

1

Try this to show images on imagesView....

UIImageView *imageView;
NSArray *arrayOfImage=[[NSArray alloc]initWithObjects:@"i1.jpg",@"i2.jpg",@"i3.png", nil];;
float x=10;
float y=50;
float width=100;
float height=100;
int i=0;
for(i=0;i<[arrayOfImage count];i++)
{
   imageView=[[UIImageView alloc]initWithFrame:CGRectMake(x+width*i, y, width, height)];
    imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
     [self.view addSubview:imageView];
}
else if(i==[arrayOfImage count])
    {
        i=0;
        imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
        [self.view addSubview:imageView];
        i++;

    }

if you want to change the I'm image on next button and back button... then try below code

- (IBAction)btnClicked:(id)sender
{

UIImageView *imageView;
NSArray *arrayOfImage=[[NSArray alloc]initWithObjects:@"i1.jpg",@"i2.jpg",@"i3.png",@"i1.jpg",@"i2.jpg",@"i3.png", nil];;
float x=100;
float y=100;
float width=100;
float height=100;

imageView=[[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
if([sender tag]==0)
{
    if(i<[arrayOfImage count])
    {
        imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
        [self.view addSubview:imageView];
        i++;
    }
    else if(i==[arrayOfImage count])
    {
        i=0;
        imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
        [self.view addSubview:imageView];
        i++;

    }

}else
{
    if(i<[arrayOfImage count])
    {
        imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
        [self.view addSubview:imageView];
        i--;
    }
    else if(i==-1)
    {
        i=0;
        imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
        [self.view addSubview:imageView];
        i++;

    }

}


}

Note: set Tag to Next button as 0 and set tag to back button as 1.

Ashok Londhe
  • 1,491
  • 11
  • 29
0

Use multiple UIImageViews and before placing them using addSubview, set them a frame, which will be different for every UIImageView.

Putting multiple images into one UIImageView is certainly possible, but achievable probably only by merging images into one, which I would not consider the best option. How to do that, you can find in accepted answer there:

iOS - Merging two images of different size

Community
  • 1
  • 1
Reconquistador
  • 885
  • 8
  • 28