-1

I have an image, on an image there are three things Spoon, Cup and basket. Now I have to identify when user click on image nothing will happen until and unless the user click on spoon, cup & basket.

If user click on spoon the spoon colour will become green. Same for cup and basket.

And I have no idea how to do this. I want some hints from experts and how and where to start?

Any idea or suggestions would be highly welcome.

Daniel Martín
  • 7,815
  • 1
  • 29
  • 34
Nisha Singh
  • 143
  • 4
  • 12
  • Sir why you downvote me? I am trying to ask question because I didnot get any suitable answer. If you know the answer please reply. This is what I want https://www.4shared.com/photo/j4K4o3h-/5e2Mv.html? Please don`t demoralise new developers. – Nisha Singh May 06 '13 at 07:25
  • No, i don't give you down vote. just mark as duplicate. your question is right. – SAMIR RATHOD May 06 '13 at 07:27

5 Answers5

0

You can try out masking of views by setting the visible parts as the images of objects and set that view with the gestures

or

Make different images for the objects set it in the selected state of button and on button click change the state to selected

[button setSelected:YES];

[button setSelected:NO];
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

Place buttons on Spoon, Cup and basket. set button.backgroundcolor = [UIColor clearcolor]; Change images in IBAction.

Ashini
  • 492
  • 3
  • 11
0

lets say your image is in backgroundImageView. You got to keep 4 images. The original image, image with green spoon, image with green cup and image with green basket. And then add custom style buttons on top of spoon, cup and basket. And connect below IBAction methods to your buttons.

- (IBAction) spoonButtonPressed{
    backgroundImageView.image = [UIImage imageNamed:@"IMAGE_WITH_GREEN_SPOON.png"];
}

- (IBAction) basketButtonPressed{
    backgroundImageView.image = [UIImage imageNamed:@"IMAGE_WITH_GREEN_BASKET.png"];
}

- (IBAction) cupButtonPressed{
    backgroundImageView.image = [UIImage imageNamed:@"IMAGE_WITH_GREEN_CUP.png"];
}
Ushan87
  • 1,608
  • 8
  • 15
0

You can start investigating UIButton.

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIButton_Class/

Make your images as Button background image in Interface builder or in code. You can do pretty much anything with image then.

bpolat
  • 3,879
  • 20
  • 26
0

Adding Buttons on your object. and go file inspector click on 5th tab make that button clear color your button dissapear. then do what you want.

also tried to set image directly on buttons

[ButtonSpoon setImage:[UIImage imageNamed:@"spoon.png"] forState:UIControlStateNormal] ;
[ButtonCup setImage:[UIImage imageNamed:@"cup.png"] forState:UIControlStateNormal] ;
[ButtonBasket setImage:[UIImage imageNamed:@"basket.png"] forState:UIControlStateNormal] ;
Jitendra
  • 5,055
  • 2
  • 22
  • 42
  • This is what I want https://www.4shared.com/photo/j4K4o3h-/5e2Mv.html? – Nisha Singh May 06 '13 at 07:21
  • NOt yet sir, please check the url- https://www.4shared.com/photo/j4K4o3h-/5e2Mv.html? – Nisha Singh May 06 '13 at 07:26
  • not exactly understand what you want. – Jitendra May 06 '13 at 07:26
  • I want to detect objects lines anything on an image. – Nisha Singh May 06 '13 at 07:28
  • Try this: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //To get tag of touch view int viewTag=[touch view].tag; if ([[touch view] isKindOfClass:[UIImageView class]]) { //Write your code... } } and set your images UserInteractionEnabled like this: [imageName setUserInteractionEnabled:YES]; – Jitendra May 06 '13 at 07:34