Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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

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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
scrolling a UIScrollView on the click of a button ashwinr87 iPhone/iPad Programming 2 Jun 17, 2011 01:00 PM
UIScrollView - Showing user more content is available on scroll ashwinr87 iPhone/iPad Programming 4 May 23, 2011 12:03 PM
UIScrollView untouchable as subclass, fine normally carlosbutler iPhone/iPad Programming 1 Apr 28, 2011 09:49 PM
drag images in & out of UIScrollview BarryK88 iPhone/iPad Programming 3 Mar 23, 2011 05:49 AM
scroll a uitextfield and a uitextview in a uiscrollview franium iPhone/iPad Programming 14 Dec 4, 2010 02:51 AM


All times are GMT -5. The time now is 06:01 AM.

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

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