0

我一直在搜索一个多图像选择器,但我偶然发现了AGImagePickerController,但是,我在 iPad 中编码,如何在 a 中显示选择popoverControlleralertView?是否可以?还是我应该通过正常方式转移它UIButton?请帮忙。

AGImagePickerController *imagePickerController = [[AGImagePickerController alloc] initWithFailureBlock:^(NSError *error) {
        NSLog(@"Fail. Error: %@", error);

    if (error == nil) {
        NSLog(@"User has cancelled.");
        [self dismissModalViewControllerAnimated:YES];
    } else {

        // We need to wait for the view controller to appear first.
        double delayInSeconds = 0.015;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            [self dismissModalViewControllerAnimated:YES];
        });
    }

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];

} andSuccessBlock:^(NSArray *info) {

    NSLog(@"Info: %@", info);
    [self.selectedPhotos setArray:info];

     }

    [self dismissModalViewControllerAnimated:YES];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}];

// Show saved photos on top
imagePickerController.shouldShowSavedPhotosOnTop = YES;
imagePickerController.selection = self.selectedPhotos;

// Custom toolbar items
AGIPCToolbarItem *selectAll = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"+ Select All" style:UIBarButtonItemStyleBordered target:nil action:nil] andSelectionBlock:^BOOL(NSUInteger index, ALAsset *asset) {
    return YES;
}];
AGIPCToolbarItem *flexible = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] andSelectionBlock:nil]; 
AGIPCToolbarItem *selectOdd = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"+ Select Odd" style:UIBarButtonItemStyleBordered target:nil action:nil] andSelectionBlock:^BOOL(NSUInteger index, ALAsset *asset) {
    return !(index % 2);
}];
AGIPCToolbarItem *deselectAll = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"- Deselect All" style:UIBarButtonItemStyleBordered target:nil action:nil] andSelectionBlock:^BOOL(NSUInteger index, ALAsset *asset) {
    return NO;
}];  
imagePickerController.toolbarItemsForSelection = [NSArray arrayWithObjects:selectAll, flexible, selectOdd, flexible, deselectAll, nil];
//    imagePickerController.toolbarItemsForSelection = [NSArray array];


imagePickerController.maximumNumberOfPhotos = 100;

[self presentModalViewController:imagePickerController animated:YES];

}

4

1 回答 1

1

您应该通过以下方式使用它Round Rect Button

self.popoverController = 
[[UIPopoverController alloc] initWithContentViewController:imagePickerController]; 

popoverController.delegate = self;

CGRect popoverRect = [self.view convertRect:[YOURBUTTON frame] 
                                   fromView:[YOURBUTTON superview]];    
popoverRect.size.width = MIN(popoverRect.size.width, 100);

[self.popoverController 
 presentPopoverFromRect:popoverRect 
 inView:self.view 
 permittedArrowDirections:UIPopoverArrowDirectionAny 
 animated:YES];

[popoverController setPopoverContentSize:CGSizeMake(1024, 500)];
于 2012-07-12T07:19:30.390 回答