How to take a picture and save in SQLite database on iOS

后端 未结 3 924
小蘑菇
小蘑菇 2021-02-06 19:33

I have a camera application in which when I click on the camera button the camera opens and user can take picture from camera or from photo-library.

I have done the came

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 19:55

    Now when you opens the camera, you implement the following method

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
    
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }
    

    in the above method add the following code :--

    NSData *imageData = UIImageJPEGRepresentation(img, 1);
    

    then call the method of saving data to database.

    Make sure you take the field type as blob in database.

    Hope it helps.....

提交回复
热议问题