我有2個imageviews與它的圖像。我希望當我點擊第一個圖像的圖像應該被選中,如果它被選中它應該返回我的價值TRUE或1應該保存在sqlite數據庫。這是可能的。請問任何人都可以幫助我解決這個問題。 感謝我們如何檢查imageview中的哪個圖像被調用
1
A
回答
0
你去觸摸events.Capture的接觸點,並執行actions.Here我會給UA樣本結構要做到這一點,
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location= [touch locationInView:self.view];
if(CGRectContainsPoint(firstImage.frame, location)) {
//set some flag like
selectionFlag=1; }
else if(CGRectContainsPoint(secImage.frame, location)){
selectionFlag=2; }
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if(CGRectContainsPoint(firstImage.frame, location)) {
if(selectionflag==1) {
//do ur db actions }
}
else if(CGRectContainsPoint(secImage.frame, location)) {
if(selectionflag==2) {
//do ur db actions }
}
selectionflag=0;
}
0
先做
[self.*yourimageViewname* setUserEnteractionEnabled:YES];
BOOL select1,secelect2;
select1=NO;
select2=NO;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
CGPoint touchLocation = [touch locationInView:touch.view];
//give the beginning and ending x and y points in condition to check which imageView is taped
if(touchLocation.x>1 && touchLocation.x<116 && touchLocation.y>133 && touchLocation.y<233)
{
select1=YES;
}
else if(touchLocation.x>120 && touchLocation.x<300 && touchLocation.y>133 && touchLocation.y<233)
{
select2=YES;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
}
在條件,布爾變量是真的,你可以保存或任何你想做的進一步編碼您的應用程序。
0
1
通過使用UITouch類的方法,你會得到哪個圖像視圖觸摸..或者你可以把imageview裏面的按鈕,然後你會得到點擊事件。
0
你還可以做的是創建兩個按鈕(而不是UIImageViews)有圖像。他們應該顯示大致相同的(你甚至可以禁用觸摸狀態等)。您可以免費獲得UIResponder事件(如在;您可以將操作定位到選擇器)。
更新:這裏大概是如何(雖然沒有打擾配置按鈕)。
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setImage:yourImage forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchUpInside];
// .. now create a second button .. //
,觸碰到你的按鈕將進入下面的方法:
- (void)buttonTouched:(id)sender
{
// .. add your stuff to your database .. //
// .. you can identify your button by sender, or give the button a tag (number) to identify it ../
}
相關問題
- 1. 如何檢查哪個圖像鏈接到android中的ImageView?
- 2. 如何檢查哪個表被調用postgresql中的哪個觸發器?
- 3. solr如何檢查哪個查詢解析器被調用?
- 4. 檢查圖像被使用在哪個頁面上?
- 5. 如何檢查我在C#中調用哪個按鈕?
- 6. 如何識別哪個imageView被觸摸?
- 7. 如何檢查ImageView中設置的圖像
- 8. ImageView包含圖像的案例檢查
- 9. 如何用imageview查找圖像名稱?
- 10. 我如何檢查圖像是否已被查看?
- 11. Android:如何檢查使用哪個相機拍攝圖像
- 12. 我們如何檢查對象屬於哪個類?
- 13. 細胞Imageview與手勢 - 哪個圖像被挖掘?
- 14. 如何檢測哪個圖像被點擊
- 15. 哪個checkbutton已被檢查
- 16. 如何檢查哪個圖像設置爲活動視圖?
- 17. 如何在單擊該圖像時從ImageView中檢索圖像?
- 18. 如何查看哪個圖像是ViewPager中的當前圖像?
- 19. 如何檢查哪個單選按鈕(動態)被檢查?
- 20. Android ImageView檢查圖像旋轉嗎?
- 21. 如何檢查哪一個被選中或不使用jQuery
- 22. 如何檢查dataGridView中的哪個單元格被選中?
- 23. 檢測哪個圖像與圖像被點擊
- 24. 檢查在Swift中使用UITapGestureRecognizer按下哪個圖像視圖
- 25. 如何檢查按鈕背景上的哪個圖像
- 26. WCF檢測哪個綁定被調用
- 27. 我如何檢查圖像的類型?
- 28. 我如何檢查imageview是否爲空
- 29. 我們如何檢查AutomationElement是否被選中c#
- 30. 我如何檢測在Android中已被觸摸的所有ImageView?
您可以使用觸摸方法通過觸摸方法U將得到該圖像視圖觸摸實施這一 – Gypsa 2011-04-27 10:14:34
..並在選擇從圖像視圖獲取圖像並將圖像數據轉儲到文件而不是數據庫。 – santosh 2011-04-27 10:26:13
其實我不能正確得到你可以請你詳細解釋我。謝謝 – Rani 2011-04-27 10:31:06