Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 14, 2009, 05:32 PM   #1
iphoneSDKrules
macrumors newbie
 
Join Date: Aug 2008
UIScrollView + pagingEnabled, scroll half a page?

Hello,

can anyone tell me if it is possible, to scroll half a page in a UIScrollView with pagingEnabled = true.

As far as I know, the amount of scrolling when pagingEnabled depends on the frame size of the ScrollView, so it scrolls exactly one page.What I'd like to do is scrolling exactly half a page: my ScrollView contains two images on each 'page' and after scrolling I don't want to display the next two images, but the second image of the previous page + the first image of the next page and so on...

I'd be so glad if anyone could tell me how to do so.

thanks for your help, kate
iphoneSDKrules is offline   0 Reply With Quote
Old Jan 14, 2009, 09:37 PM   #2
walty
macrumors member
 
Join Date: Jul 2008
hm.. I have seen such scenario (as a bug) in uitableview, but not sure if it worked the same as uiscrollview.

have u tried to make the frame size of the scrollview TWICE the size of screen? in that way, the second half may never be scrolled to.
walty is offline   0 Reply With Quote
Old Jan 15, 2009, 11:20 AM   #3
zkiraly
macrumors newbie
 
Join Date: Jan 2009
I am also interested in the same. Right now I have a workaround in place, but being able to page arbitrary distances would be nice.

Zsolt
zkiraly is offline   0 Reply With Quote
Old Jan 15, 2009, 11:42 AM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by zkiraly View Post
I am also interested in the same. Right now I have a workaround in place, but being able to page arbitrary distances would be nice
That doesn't sound like paging to me, which, as I understand it, is scrolling non-arbitrary distances.

My suggestion to everyone would be to set pagingEnabled = NO and scrollingEnabled = NO and then capture the swipe events and then call scrollRectToVisible to scroll to where you want it. I'm not certain this will work but it's worth a shot.
dejo is offline   0 Reply With Quote
Old Jan 15, 2009, 02:26 PM   #5
zkiraly
macrumors newbie
 
Join Date: Jan 2009
Quote:
Originally Posted by dejo View Post
My suggestion to everyone would be to set pagingEnabled = NO and scrollingEnabled = NO and then capture the swipe events and then call scrollRectToVisible to scroll to where you want it. I'm not certain this will work but it's worth a shot.
Thanks for the suggestion. Actually, that's what I do now. But there is no 'bounce' at the end, like in the weather app.

I think this is still 'paging.' Imagine the weather app, but zoomed out, so you see a portion of the adjoining pages as well. That's kinda what I'd like to accomplish in my own app.
zkiraly is offline   0 Reply With Quote
Old Jan 16, 2009, 11:12 AM   #6
iphoneSDKrules
Thread Starter
macrumors newbie
 
Join Date: Aug 2008
Quote:
Originally Posted by dejo View Post
My suggestion to everyone would be to set pagingEnabled = NO and scrollingEnabled = NO and then capture the swipe events and then call scrollRectToVisible to scroll to where you want it. I'm not certain this will work but it's worth a shot.
Thank you! That solves my problem!
I set paginEnabled + scrollingEnabled to NO and capture swipes using the touchesBegan and touchesEnded methods. Depending on a positive or negative yDistance between the two touch locations, I call the scrollRectToVisible in order to scroll half a page forward or backward, which works really well!
iphoneSDKrules is offline   0 Reply With Quote
Old Mar 12, 2009, 04:45 AM   #7
coconutdj
macrumors newbie
 
Join Date: Mar 2009
hi iphoneSdkRules,
i have the same problem , i want to scroll a half page, can you send me that piece of code to see hot to do this ?
" I set paginEnabled + scrollingEnabled to NO and capture swipes using the touchesBegan and touchesEnded methods. Depending on a positive or negative yDistance between the two touch locations, I call the scrollRectToVisible in order to scroll half a page forward or backward, which works really well! "

Thanks
coconut_dj@yahoo.com
coconutdj is offline   0 Reply With Quote
Old Mar 25, 2009, 08:16 AM   #8
iphoneSDKrules
Thread Starter
macrumors newbie
 
Join Date: Aug 2008
hi, this is what i did in touchesBegan & touchesEnded methods:

PHP Code:
#define SCROLLOFFSET 60

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    
NSLog(@"TOUCHES BEGAN!");
    
    
UITouchtouch = [touches anyObject];
    
touchDown = [touch locationInView:self.view];
}

- (
void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
    
NSLog(@"TOUCHES ENDED!");
    
    
UITouchtouch = [touches anyObject];
    
touchUp = [touch locationInView:[[self.view subviewsobjectAtIndex:0]];
    
    
//calculate dragging distance
    
double dy touchUp.touchDown.y;
    
double dx touchUp.touchDown.x;
    
    
NSLog(@"touchDown x: %d, y: %d"touchDown.xtouchDown.y);
    
NSLog(@"touchUp x: %d, y:%d"touchUp.xtouchUp.y);
    
NSLog(@"distance between touches: %d"dy);

    if(
abs(dy) > SCROLLOFFSET)
    {
        if(
dy 0)
            [
self scrollForward];
        else
            [
self scrollBackward];
    }

touchUp and touchDown are both CGPoints, the scrollForward and scrollBackward are used to call the scrollRectToVisible method with a calculated offset.

hope that helps
iphoneSDKrules is offline   0 Reply With Quote
Old Apr 7, 2009, 03:20 AM   #9
Goblin2099
macrumors member
 
Join Date: Jul 2002
Location: New York City
Send a message via AIM to Goblin2099
Check out this post for another way to accomplish half screen paging
Goblin2099 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: Opening NC makes page scroll up wargnerm Jailbreaks and iOS Hacks 4 Jan 30, 2014 08:35 AM
Resolved: UIScrollView does not scroll a UIImageView Tex-Twil iPhone/iPad Programming 4 Nov 20, 2013 06:57 AM
Looking for PDF reading app with half page turns wichad iPad Apps 15 Oct 28, 2013 05:46 PM
Safari crashes when you scroll down this page ccsicecoke OS X 4 Sep 8, 2013 10:07 AM
How scroll and back page gestures barrk OS X 10.8 Mountain Lion 18 Aug 23, 2012 04:32 PM

Forum Jump

All times are GMT -5. The time now is 09:36 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC