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-23-2011, 05:52 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default Use a gesture inside a scrollview (bring content out of the scrollview with gestures)

Inside my UIScrollView I've got a view. Within this view there are several images. I'd like to drag the images out of my scroller (and view) to the mainview. However getting the images in front of the scroller and view is driving me bonkers.

This is a piece of my code:

Code:
- (void)viewDidLoad{

    //scroller properties
    scroller.contentSize = CGSizeMake(1300, 130);
    scroller.scrollEnabled = YES;
    scroller.directionalLockEnabled =YES;
    scroller.frame = CGRectMake(0, 874, 768, 130);
    [scroller setDelegate:self];

    UIView *contentContainer = [[UIView alloc] init];

    [scroller addSubview:contentContainer];
    [scroller addSubview:image1];
    [scroller bringSubviewToFront:image1];
    [speler1 release];

    UILongPressGestureRecognizer *longPress1 =
    [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressed:)];
    [image1 addGestureRecognizer:longPress1];
    [longPress1 release];

    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc]  initWithTarget:self action:@selector(move:)];
    [panRecognizer setMinimumNumberOfTouches:1];
    [panRecognizer setMaximumNumberOfTouches:1];
    [panRecognizer setDelegate:self];
    [image1 addGestureRecognizer:panRecognizer];


}

-(void)longPressed:(UILongPressGestureRecognizer *)sender {

    [[self.view superview] bringSubviewToFront:image1];

}

-(void)move:(id)sender {

    //move the image

}
I'd like to bring the images in front of the views by using a LongPressGestureRecognizer. The PanGestureRecognizer takes care of moving the image. The dragging works only inside the scrollview. Anyone knows how to bring my images in front of the views?

Help is greatly appreciated
BarryK88 is offline   Reply With Quote
Old 03-27-2011, 12:50 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 7
chimera247 is on a distinguished road
Default same problem here!

did you fix it?
chimera247 is offline   Reply With Quote
Old 03-29-2011, 02:17 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default

I fixed it by using [self.view addSubview image] within my longpressgesturerecognizer method.

After the longpress is done the panrecognizer comes to action which drags the image on the mainview.

Does this answers your question?
BarryK88 is offline   Reply With Quote
Old 04-10-2011, 04:53 AM   #4 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 7
chimera247 is on a distinguished road
Default

Well, i just read your post, i am going to try it out, right now.
Thanks for answering!!!
Hope i get it to work
chimera247 is offline   Reply With Quote
Reply

Bookmarks

Tags
drag, image, subview, uigesturereconizer, uiscrollview

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

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