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 09-02-2011, 01:52 AM   #1 (permalink)
Student
 
Join Date: Sep 2011
Posts: 2
cslew2009 is on a distinguished road
Default Subviews in UIScrollViews to page subview by subview instead of scrollview size

Hi. I've subviews (UIImageViews) inside a UIScrollView.

I'm trying to enable the subviews to be scrolled one by one. However, if I am to enable paging, the paging will page the by the size of the entire UIScrollView .

Also, if I'm to reduce the size of UIScrollView to fit just one subview and clipToBounds=YES. My gestures can only be detected when the touch is within the boundaries of the UIScrollView, which is not untuitive enough.

So my question is: What can I do to ensure that my scrollview is able to page one subview by one subview? Thank you.
cslew2009 is offline   Reply With Quote
Old 09-03-2011, 10:14 AM   #2 (permalink)
Student
 
Join Date: Sep 2011
Posts: 2
cslew2009 is on a distinguished road
Default

Found the solution.

I wrote a custom UIView class which overrides the hitTest method of UIView.

In the header of the custom UIView class, declare a UIScrollView, later you will need to assign the UIScrollView which is displaying the menu to this variable.

Code:
UIScrollView *thatScrollView;
In the implementation, remember to synthesize the variable and overwrite hitTest

Code:
   @synthesize thatScrollView;
    
    - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        if ([self pointInside:point withEvent:event]) {
            return thatScrollView;
        }
        return nil;
    }
Then in the UIViewController class, create an instance of the class and assign the scrollview you want to scroll:

Code:
  <instance of custom UIView>.underneathButton = scrollView1;

Last edited by cslew2009; 09-03-2011 at 10:16 AM.
cslew2009 is offline   Reply With Quote
Reply

Bookmarks

Tags
scrolling, uiscrollvew

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: 392
5 members and 387 guests
JackReidy, jeroenkeij, Sami Gh, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

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