0

フォト ライブラリまたは iPhone に最適なカメラからファイルを添付するためのコーディングがあります。しかし、iPAD の場合、popUpViewController を使用する必要があることがわかりました。iPad に写真を添付するためのコードを提案できる人はいますか?

そして私のコードは

-(void)openCamera
{
@try
{
      UIImagePickerController *picker = [[UIImagePickerController alloc] init];
      picker.delegate = self;
      picker.sourceType = UIImagePickerControllerSourceTypeCamera;
      picker.navigationBar.tintColor = [UIColor blackColor];
      [self.navigationController presentViewController:picker animated:YES completion:nil];



}
@catch (NSException *exception)
{
    CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:@"No Camera"
                                                            message:@"Camera is not available  "
                                                           delegate:self cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
    [alert show];

}
}

-(void)pick
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.navigationBar.tintColor = [UIColor blackColor];
[self presentViewController:picker animated:YES completion:nil];

}

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

if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
{

    [picker dismissViewControllerAnimated:YES completion:nil];

    UIImage *fullImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];

    UIImage *thumbImage = [fullImage imageByScalingAndCroppingForSize:CGSizeMake(180,180)];
    self.detailItem.fullImage = fullImage;
    self.detailItem.thumbImage = thumbImage;

    NSData *dataObj = UIImagePNGRepresentation(thumbImage);
    base64String=[dataObj base64Encoding];

    NSDate *currentDateTime = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MMddyyyy_HHmmss"];
    NSString *dateInStringFormated = [dateFormatter stringFromDate:currentDateTime];

    fileName = [NSString stringWithFormat:@"IMG_%@.png",dateInStringFormated];

    [self Uploadfile];
}
else
{
    [picker dismissViewControllerAnimated:YES completion:nil];

    UIImage *fullImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];


    UIImage *thumbImage = [fullImage imageByScalingAndCroppingForSize:CGSizeMake(180,180)];
    self.detailItem.fullImage = fullImage;
    self.detailItem.thumbImage = thumbImage;

    NSData *dataObj = UIImagePNGRepresentation(thumbImage);
    base64String=[dataObj base64Encoding];

    NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];
    ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
    {
        ALAssetRepresentation *representation = [myasset defaultRepresentation];
        fileName = [representation filename];
        NSLog(@"fileName siva : %@",fileName);
        [self Uploadfile];

    };

    ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
    [assetslibrary assetForURL:imageURL
                   resultBlock:resultblock
                  failureBlock:nil];       



}


}
4

2 に答える 2

0

ポップオーバー内のユーザー画像ピッカー。

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
于 2013-07-24T12:55:56.107 に答える