我有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. 如何检查哪个表被调用postgresql中的哪个触发器?
- 2. solr如何检查哪个查询解析器被调用?
- 3. 如何检查我在C#中调用哪个按钮?
- 4. 如何检查ImageView中设置的图像
- 5. 如何用imageview查找图像名称?
- 6. 我们如何检查对象属于哪个类?
- 7. 哪个checkbutton已被检查
- 8. 如何检查哪个图像设置为活动视图?
- 9. 如何查看哪个图像是ViewPager中的当前图像?
- 10. 如何检查哪个单选按钮(动态)被检查?
- 11. 如何检查哪一个被选中或不使用jQuery
- 12. 检测哪个图像与图像被点击
- 13. 我如何检查图像的类型?
- 14. 我如何检查imageview是否为空
- 15. 检查哪个图像已设置为图像视图
- 16. 检索ImageView中的“Clean”图像
- 17. 如何防止imageview中的图像被裁剪为正方形?
- 18. 如何检查哪个图像listview包含?
- 19. 在imageView中调用图像distory生成的图像
- 20. 如何检查imageview中的源代码?
- 21. asterisk命令来检查哪个DID被调用(星号)
- 22. jquery:我们可以检测哪个链接被点击从ajaxStart
- 23. firebug - 我如何检测函数被调用或从哪里调用函数
- 24. 如何检查是否一个imageview的有它的图像,并跳过下一ImageView的
- 25. 调整线条以适应我们的头像imageview
- 26. 如何从所有图像检查宽度和高度已被jquery调用?
- 27. 跟踪图像列表中的哪个图像被点击?
- 28. 如何查看哪个dll被我的应用程序加载?
- 29. 如何将图像从一个ImageView截取到另一个ImageView
- 30. 如何更新imageview中的图像?
您可以使用触摸方法通过触摸方法U将得到该图像视图触摸实施这一 – Gypsa 2011-04-27 10:14:34
..并在选择从图像视图获取图像并将图像数据转储到文件而不是数据库。 – santosh 2011-04-27 10:26:13
其实我不能正确得到你可以请你详细解释我。谢谢 – Rani 2011-04-27 10:31:06