我正在使用AGImagePickerController
. 我很难弄清楚如何将选择的图像导入到iCarousel
另一个轮播中。我知道其中success block
包含所选图像。我似乎无法将其导入我的awakeFromNib
或将其放入数组中。
这是我调用 AGImagePickerController 的代码:
-(IBAction) cameraRoll {AGImagePickerController *imagePickerController = [[AGImagePickerController alloc] initWithFailureBlock:^(NSError *error) {
if (error == nil)
{
NSLog(@"User has cancelled.");
[self dismissModalViewControllerAnimated:YES];
} else
{
NSLog(@"Error: %@", error);
// Wait for the view controller to show first and hide it after that
double delayInSeconds = 0.5;
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 dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}];
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
}
在我的 awakeFromNib 中:
- (void)awakeFromNib
{
if (self) {
self.images = [NSMutableArray arrayWithObjects:@"111.jpg",
@"112.jpg",
@"113.jpg",
@"114.jpg",
@"115.jpg",
@"116.jpg",
@"117.jpg",
@"118.png",
@"119.jpg",
@"120.jpg",
nil];
}
}
然后我为我的轮播实现这个:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{
//create a numbered view
UIView *view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[images objectAtIndex:index]]];
return view;
}