简体   繁体   中英

How to display or pass camera capture image into other views in iphone

I am new to i phone programming.Once i capture picture that picture iam displaying in same view,after applying image filter effect i have taken preview button if i click on preview button means same image i want to display in another view but image is not going to next view.how can i do this can any body help me.Inside preview button i have given this below code Thanks

preview *p=[[preview alloc]init];
p.secondimageviewobject= firstimageviewobject.image;
[self presentModalViewController:p animated:YES];

Well for this kind of method, you would have to create a singleton class like ShareClass.h or if you are really new (and dont know about this) , in the AppDelegate.h wherein you would have to declare a UIImage say UIImage *SavedImage .

Now call this class in the view where you are capturing the image . Then save this captured image in the SavedImage . To share this image you would then call the ShareClass.h class or the AppDelegate.h in the view in which you want to share the image and display it in the UIImageView .

Any clarifications please ask. :)

In the ShareClass.h

UIImage *SavedImage;
@interface ShareClass : NSObject
{

}

In the Class where the image was captured, First import the ShareClass.h , then

        imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
            imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            SavedImage = UIImagePickerControllerSourceTypeCamera;
            [self presentViewController:imagepicker animated:YES completion:NULL];                
        }

In the Class where the image should be displayed again import the ShareClass.h

UIImageView *DisplayImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:SavedImage]];
DisplayImage.frame=CGRectMake(0, 0, 20, 20);
[self.view addSubView:DisplayImage];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM