开发者

Add 2 images to separate UIImageView

I hava an app where i need to add 2 or more images. The images should be displayed in UIImageview. I use two separate buttons to add 2 images. i am able to add only one image. When i choose the second button, the image gets displayed on the first UIImageview. Here is the code where i do it.

- (void)imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info {
    if(choosePhoto1){

       NSLog(@"buttonclicked:button1");

       theimageView1.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
       [picker dismissModalViewControllerAnimated:YES];

    }
    else if(choosePhoto2) {
         NSLog(@"buttonclicked:button2");

         theimageView2.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

         [picker dismissModalViewControllerAnimate开发者_StackOverflowd:YES];
   }

}

I want to know if this is the right way to do it or is there any other method. I looked in to the forums but there is no method for adding 2 pictures. Any help is appreciated.

Thanks Viki


One UIImageView displays a single image. If you want to display two different images in two different places at the same time, then you need two UIImageView objects. If you do have two UIImageView objects, and only one is changing, perhaps in interface builder you set both outlets to one UIImageView?


If your Interface Builder connections are all correct, I'd suggest inspecting your values for choosePhoto1 and choosePhoto2. Are you sure these are set to the correct values when you click the buttons? (Maybe show that code too). I'd guess you are toggling the values of them like so:

- (IBAction)btnOneClicked:(id)sender {
  self.choosePhoto1 = YES;
  self.choosePhoto2 = NO;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜