【发布时间】:2013-04-18 10:20:39
【问题描述】:
我在UICollectionView 中显示了一组图像。当用户点击图像时,它会生成一个UIActionSheet,其中包含该图像的一些选项。其中一个从UICollectionView 中删除了照片。当用户在UIActionSheet 中选择删除按钮时,它会弹出一个警报视图,要求确认。如果用户选择是,它应该删除照片。
我的问题是,要从UICollectionView 中删除项目,您必须将indexPath 传递给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
{
}
【问题讨论】:
标签: ios uicollectionview uialertview uiactionsheet