Stack UIImagePickerController上的滚动视图

时间:2010-04-15 20:23:38

标签: iphone-sdk-3.0 overlay uiimagepickercontroller

我想首先说除了教程示例之外,我对其他任何东西都有点新鲜,如果这是一个愚蠢的问题,那就很抱歉。

我已经稍微修改了一些示例代码,以便在用户选择图像后,它不会关闭UIImagePickerController,而是在后台处理它。

这看起来效果很好,但是一旦用户选择了他们想要处理的所有图像,他们所呈现的唯一按钮就是“取消”。

我希望更改代码,以便将所选图像添加到图像选择器底部的滚动视图中,但无法找到将任何内容堆叠或叠加到UIImagePickerController视图上的方法。

我到目前为止的代码如下:

-(IBAction)LoadPhotoAlbums:(id)sender
{
NSLog(@"LoadPhotoAlbums");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 

if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
    return;
}

if(photoPicker == NULL) {
    photoPicker = [[UIImagePickerController alloc] init];
    photoPicker.delegate = self;
    photoPicker.allowsImageEditing = NO;
}

photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;


[self presentModalViewController:photoPicker animated:YES];
[pool release];
}



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

    if([[info objectForKey:@"UIImagePickerControllerMediaType"] isEqualToString:K_UI_TYPE_IMAGE])
    {
        NSLog(@"Image Selected");
        selectedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
        NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
        [dateFormatter setDateFormat:@"ddMMMyyyyHHmmss"];
        NSString *date = [dateFormatter stringFromDate:[NSDate date]];

        NSData *imageData = UIImageJPEGRepresentation(selectedImage,0.9);

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        selectedImagePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg", date]];
        NSLog(@"Image path is %@", selectedImagePath);

        if([imageData writeToFile:selectedImagePath atomically:YES])
            NSLog(@"Write Successful");
    }

    //[picker dismissModalViewControllerAnimated:YES];
    //add to listofimages view.
    [self uploadSelectedImage];
}

0 个答案:

没有答案