0

我似乎在删除 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];

}
4

2 回答 2

3

您将需要从超级视图中删除视图,如下所示

//In your button clicked function
- (IBAction)buttonClicked:(id)sender {
    UIButton *button = (UIButton *)sender;
    [button removeFromSuperView];
}
于 2012-06-18T07:23:05.897 回答
0

我想在完成你的删除选项之后。你不会重新加载你的视图。所以我保持那个形象。

于 2012-06-18T07:26:08.113 回答