2012-06-18 50 views
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]; 

} 

回答

3

您將需要從超級視圖中刪除視圖類似下面

//In your button clicked function 
- (IBAction)buttonClicked:(id)sender { 
    UIButton *button = (UIButton *)sender; 
    [button removeFromSuperView]; 
} 
+0

它不起作用。想要它在'buttonClick'裏面 – Bazinga

+0

告訴我們如何將圖像添加到滾動視圖 –

+0

完成。編輯過它。這是整個實施。 – Bazinga

0

我覺得你完成刪除選項之後。你不重新加載你的觀點。讓我保持那個形象。