ここに示すようにiCarouselを使用していますが、カメラまたはイメージピッカーから写真を撮って動的に画像を追加したいと思います。以下は私のコードです、
- (void)loadView {
[super loadView];
imagesArray = [[NSMutableArray alloc]init] ;
// Initialize and configure the carousel
carousel = [[iCarousel alloc] initWithFrame:CGRectMake(0,50, 100, 100)];
carousel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
carousel.type = iCarouselTypeCoverFlow;
carousel.dataSource = self;
[self.view addSubview:carousel];
}
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return [imagesArray count];
}
- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel
{
//note: placeholder views are only displayed on some carousels if wrapping is disabled
return [imagesArray count];
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{
UIImage *image = [imagesArray objectAtIndex:index];
UIButton *button = [[[UIButton alloc] initWithFrame:CGRectMake(0,50,100, 100)] autorelease];
[button setBackgroundImage:image forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
button.titleLabel.font = [button.titleLabel.font fontWithSize:50];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
button.tag=index;
return button;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[imagesArray addObject:image];
NSLog(@"array count is %d",[imagesArray count]);
[picker dismissModalViewControllerAnimated:YES];
}
画像を配列に追加することもできますが、coverflowでimageViewに表示される画像は1つだけです。誰か助けてくれませんか。