UICollectionView
에 표시되는 일련의 이미지가 있습니다. 사용자가 이미지를 탭하면 해당 이미지에 대해 몇 가지 옵션이있는 UIActionSheet
이 생성됩니다. 그들 중 하나가 UICollectionView
에서 사진을 제거하고 있습니다. 사용자가 UIActionSheet
에서 제거 버튼을 선택하면 확인을 요청하는 경고보기가 나타납니다. 사용자가 예를 선택하면 사진이 제거됩니다.UICollectionView에서 항목 제거
내 문제는 UICollectionView
에서 항목을 제거하려면 을 deleteItemsAtIndexPaths
이벤트로 전달해야합니다. 경고 확인의 didDismissWithButtonIndex
이벤트에서 최종 확인이 부여 되었기 때문에 선택한 이미지의 indexPath
을 deleteItemsAtIndexPaths
이벤트로 전달하는 방법을 알아낼 수 없습니다. 어떻게해야합니까? 여기
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
deletePhotoConfirmAlert = [[UIAlertView alloc] initWithTitle:@"Remove Photo"
message:@"Do you want to remove this photo?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil, nil];
[deletePhotoConfirmAlert addButtonWithTitle:@"Yes"];
[deletePhotoConfirmAlert show];
break;
case 1:
NSLog(@"To Edit photo");
break;
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (alertView == deletePhotoConfirmAlert) {
if (buttonIndex == 1) {
// Permission to delete the button is granted here.
// From here deleteItemsAtIndexPaths event should be called with the indexPath
}
}
}
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths
{
}
는 ** 'SomeViewController'에 대한 눈에 띄는 @interface 라인'[자기 deleteItemsFromDataSourceAtIndexPaths에서 선택한 'deleteItemsFromDataSourceAtIndexPaths'** 오류를 선언하지 않는 : selectedItemsIndexPaths를 ]; – Isuru
Sory 내가 포인트를 잊어 버렸습니다. __deleteItemsFromDataSourceAtIndexPaths__는 데이터 소스 배열에서 선택한 이미지를 삭제하는 사용자 정의 함수입니다. 직접 그곳에서 작업을 수행 할 수 있습니다. __deleteItemsAtIndexPaths를 호출하기 전에 데이터 소스 배열에서 이미지를 삭제하는 것이 중요합니다. __ –
알 수 있습니다. 이제'removeObjectAtIndex'를 사용하여 데이터 소스 배열에서 이미지를 제거하려고합니다. 그러나 정수 값을 기대하기 때문에 어떻게'selectedItemsIndexPaths' 배열에서 그것을 얻을 수 있습니까? – Isuru