我是 iPhone 应用程序的新手。
我想要的是将图像保存在服务器上。我有的是按钮。单击时,它要求提供照片或库,然后我选择图像。
但我不知道如何在服务器上保存这个图像。
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)theActionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
[self takePhotoCam];
} else if (buttonIndex == 1) {
[self choosePhotoFromLibrary];
}
}
- (IBAction)takePhotoAction:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Take Photo", @"Choose From Library", nil];
[actionSheet showInView:self.view];
} else {
[self choosePhotoFromLibrary];
}
}
- (void)takePhotoCam {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self.navigationController presentViewController:imagePicker animated:YES completion:nil];
}
- (void)choosePhotoFromLibrary {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self.navigationController presentViewController:imagePicker animated:YES completion:nil];
}