一千萬個為什麽

搜索

Stack 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];
}

最佳答案

暫時沒有最佳答案

轉載註明原文: Stack UIImagePickerController上的滾動視圖