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-22-2011, 06:15 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default Gesture recognizer within a UIScrollview

I've got a scroller within my view and got several images inside this scroller.

I'd like to drag and drop these images out (and into) my scroller. I implemented a LongPressGestureRecognizer.

I also would like to know (by code) which image got longpressed. I thought I fixed this last one by using CGRectContainsPoint. However my code is not reacting to the CGRectContainsPoint. It still Logs "fail".



Code:
 - (void)viewDidLoad{
    
    	//scroller properties
    	scroller.contentSize = CGSizeMake(1300, 130);
    	scroller.scrollEnabled = YES;
    	scroller.directionalLockEnabled =YES;
    	scroller.frame = CGRectMake(0, 874, 768, 130);
    	
    	UILongPressGestureRecognizer *longPress =
    	[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressed:)];
    	
    	[image1 addGestureRecognizer:longPress];
    	[image2 addGestureRecognizer:longPress];
    	[image3 addGestureRecognizer:longPress];
    	[longPress release];
    	
    }
    
    -(void)longPressed:(UILongPressGestureRecognizer *)sender {
    
    	
    	CGPoint location = [sender locationInView:self.view];
    	
    	if(CGRectContainsPoint(image1.frame,  location)) {
    		NSLog(@"image1 has been longpressed");
    		// do something
    	}
    
    	if(CGRectContainsPoint(image2.frame,  location)) {
    		NSLog(@"image2 has been longpressed");
    		// do something
    	}
    
    	if(CGRectContainsPoint(image3.frame,  location)) {
    		NSLog(@"image3 has been longpressed");
    		// do something
  

      	}

             else {
                     NSLog(@"fail");
    }
Has someone got experience with this LongPressGestureRecognizer and the number of images that can respond to this function?

Thanks in advance!
BarryK88 is offline   Reply With Quote
Reply

Bookmarks

Tags
drag, gesturerecognizer, image, scroller

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: 346
9 members and 337 guests
condor304, Domele, dreamdash3, LEARN2MAKE, michelle, mistergreen2011, Sami Gh, shagor012, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,662
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, shagor012
Powered by vBadvanced CMPS v3.1.0

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