我似乎在删除 UIScrollView 中的图像时遇到问题。我能够从中删除它,NSDocumentDirectory
但它仍然留在视图中。按下按钮时如何将其删除。这是我的代码:
- (IBAction)buttonClicked:(id)sender {
UIButton *button = (UIButton *)sender;
[_images objectAtIndex:button.tag];
[_images removeObjectAtIndex:button.tag];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.png", button.tag]];
[fileManager removeItemAtPath: fullPath error:NULL];
}