0
我是Xcode的新手。這對你來說可能是一個非常簡單的問題,但我想知道是否有人可以幫助我。如何更改定製的UIImageView類中的圖像
我想要做的是在定製的UIImageView中加載圖像,點擊圖像時,imageview將更改爲其他圖像。當我運行模擬器時,沒有錯誤消息,但單擊後不會加載第二個圖像。
我宣佈一個UIImageView子類dragView。在dragView.m,我有這樣的代碼:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self changePicture];
}
-(void) changePicture {
NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"Red Flower.png"];
self.image = [UIImage imageWithContentsOfFile:path];
}
順便說一句,我已經啓用的相互作用。非常感謝!