我正在使用AGImagePickerController
。我很難搞清楚如何將選中的圖像導入我的iCarousel
這是另一個傳送帶。我知道其中的success block
包含選定的圖像。我似乎無法將其導入我的awakeFromNib
或將其放入數組中。確定AGImagePickerController中的選定照片
這裏是我的代碼調用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;
}
我會把它放入我的iCarousel的awakeFromNib嗎? – Bazinga 2012-05-26 16:33:45
此代碼會進入您提供的代碼的successBlock。沒有看到你的iCarousel代碼,我無法幫助你。 – 2012-05-26 17:20:29
我編輯了我的答案。希望你能再次檢查。 – Bazinga 2012-05-27 14:36:20