iCarousel을 그림과 같이 here 캐 러셀 유형의 라이너 캐 러셀과 함께 사용하고 삭제 기능을 구현했습니다. 회전식으로 이미지를 삭제할 수 있으며 다른 이미지를 삭제하려고 시도합니다. 가시 화면에서 iomage 회전식 프레임으로 이동하여 삭제합니다.
원래 위치에서 이미지를 삭제해야합니다.iCarousel iphone에서 다른 위치의 이미지 삭제 기능을 구현하는 방법
- (void)loadView {
[super loadView];
self.view.backgroundColor = [UIColor blackColor];
carousel = [[iCarousel alloc] initWithFrame:CGRectMake(-130,300, 320, 100)];
carousel.dataSource = self;
carousel.delegate=self;
carousel.type = iCarouselTypeLinear;
carousel.scrollEnabled=YES;
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(60, 50, 200, 200)];
[self.view addSubview:imageView];
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UIImage *image = [imagesArray objectAtIndex:index];
UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0,0, 60, 60);
[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;
NSLog(@"tag is %d",button.tag);
UIButton *deleteButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
deleteButton.frame= CGRectMake(50, -5, 20 ,20);
UIImage *img = [UIImage imageNamed:@"close.png"];
[deleteButton setImage:img forState:UIControlStateNormal];
[deleteButton addTarget:self action:@selector(deleteButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button addSubview:deleteButton];
return button;
}
-(void)deleteButtonClicked:(int)sender
{
NSInteger currentIndex = carousel.currentItemIndex;
[carousel removeItemAtIndex:currentIndex animated:YES];
}
제발 도와주세요.
NSInteger index = carousel.currentItemIndex;
[carousel removeItemAtIndex:index animated:YES];
[imagesArray removeObjectAtIndex:index];
가이 추가 :
배열에서 삭제 하시겠습니까? 원래 위치에서 이미지를 삭제하면 무엇을 의미합니까? – Bazinga
- (BOOL) 회전식 고정대 : (iCarousel *) 회전식 개폐구 { return NO; } 이미 내 코드에서 이것을 사용하고 있습니다. – Valli
그것이 현재 위치에있을 때 IT 부서에서 삭제해야합니다. 그러나 코드를 사용하여 caroselframe 위치로 스크롤됩니다. – Valli