Reputation: 2466
I seem to be having a problem removing the image in UIScrollView. I was able to remove it from NSDocumentDirectory
but it still stays in the view. how to remove it when button is pressed too. Here is my code :
- (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];
}
Upvotes: 0
Views: 66
Reputation: 21221
You will need to remove the view from the super view like the following
//In your button clicked function
- (IBAction)buttonClicked:(id)sender {
UIButton *button = (UIButton *)sender;
[button removeFromSuperView];
}
Upvotes: 3
Reputation: 2481
I think after finish your delete option. you doesn't reload your view. so that i remain that image.
Upvotes: 0