Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-18-2011, 05:55 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default TapRecognizer in View and Scrollview (to drag and drop images in and out of Scrollvie

I created a view and a scrollview. They both have images inside their view. I'd like to implement a method which makes it possible for the user to drag images in and out of the scroller.

I implemented a UITaprecognizer within my project however I'm not sure how to implement the next steps in my code.

like:

* how to see which image is doubletapped.
* how to make sure that only the doubletapped image is draggable.
* how to drag my image inside or outside a scrollview. (by means of a CGIntersectRect) wich replaces my image in the scroller to the image within my view.

Here's a snippit from my code

Code:
- (void)viewDidLoad{
    UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
    tap.numberOfTapsRequired = 2;
    [image1 addGestureRecognizer:tap];
    [image2 addGestureRecognizer:tap];
    [image3 addGestureRecognizer:tap];
[scroller addGestureRecognizer:tap];
    [self.view addGestureRecognizer:tap];
    [tap release];

[super viewDidLoad];
}

-(IBAction)handleDoubleTap:(UITapGestureRecognizer *)recognizer {

    NSLog(@"an image is doubletapped");
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *) event {

    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:self.view];

if ([touch view] == image1) {
        image1.center = location;
    }
if ([touch view] == image2) {
        image2.center = location;
    }
if ([touch view] == image3) {
        image3.center = location;
    }
[self checkcollision];
}

-(void)checkcollision {

//check collision here
}
Help is greatly appreciated!
BarryK88 is offline   Reply With Quote
Reply

Bookmarks

Tags
drag, drop, image, scroller, tap

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 348
12 members and 336 guests
7twenty7, chiataytuday, condor304, Creativ, Domele, dreamdash3, laureix68, LEARN2MAKE, michelle, mistergreen2011, Sami Gh, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,661
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, tinamm64
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:30 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0