2010-06-04 34 views
1

這是我第二次問這個問題。每次用戶點擊屏幕時,如何在用戶點擊的位置繪製圖像?在用戶抽頭位置繪製UIImageView

可否請你留下一個示例項目或代碼,因爲我是新iPhone編程,並有一個很難理解某些方法等 感謝, 泰特

+0

可能的重複[無法移動我的角色!請幫助!](http://stackoverflow.com/questions/2977225/cant-move-my-character-please-help) – 2010-06-04 23:08:40

+0

事實上,還有兩個海報的其他問題,以及:[使uiimageview出現時屏幕是挖掘](http://stackoverflow.com/questions/2970671/making-a-uiimageview-appear-when-screen-is-tapped)和[使圖像顯示如何](http://stackoverflow.com/questions/2970293/making-images-appear-how) – Mac 2010-06-07 23:54:59

回答

2
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 

    UITouch * touch = [touches anyObject]; 

    UIImageView * anImageView = [[UIImageView alloc] initWithImage:anImage]; 
    [anImageView setCenter:[touch locationInView:self.view]]; 
    [self.view addSubview:anImageView]; 
    [anImageView release]; 
} 

在未來,閱讀文件或使用Google。

+0

好的非常感謝你對不起,但我真的不喜歡這個文檔。再次謝謝你。 Tate – tallen11 2010-06-05 13:50:55

+0

無論您是否喜歡該文檔,您都必須使用它。你不能總是要求其他人爲你提供代碼。這可能是值得購買許多iPhone書籍之一或遵循一些在線教程。 Google似乎很擅長查找內容。 – 2010-06-05 14:14:50