scrolling in both direction???

Discussion in 'iOS Programming' started by anuroop, May 1, 2009.

  1. macrumors newbie

    Joined:
    Mar 26, 2009
    #1
    hi all,
    I am new to iphone programming and i hav given a task of scrolling in both direction.
    Actually I have a view and I want to scroll it in both direction I mean horizontally as well as vertically but not diagnolly.
    I wiil be very thank full if some buddy tell me how to do that or if u provide me the code also.

    Anuroop Singhal
     
  2. macrumors regular

    Joined:
    Apr 9, 2009
  3. macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #3
    Use a UIScrollView, but set directionalLockEnabled to YES. This way, as soon as it someone starts scrolling one way, they can't scroll the other until they stop scrolling and start scrolling the other way.
     
  4. thread starter macrumors newbie

    Joined:
    Mar 26, 2009
    #4
    sill in problem

    i m totally confused how to do this.....there is a app at developer site of pagecontrol but it has scrolling in one direction only
    and i want scrolling in both direction and not in diagnol direction
     
  5. macrumors regular

    Joined:
    Apr 9, 2009
    #5
    it's really very simple. use a UIScrollView. it already provides scrolling in horizontal and vertical direction. and if you set the directionalLockEnabled property to YES, then the user can only scroll in one direction at a time, so no diagonally scrolling.

    http://developer.apple.com/iphone/l...IScrollView_Class/Reference/UIScrollView.html
     
  6. macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #6
    It's verrry simple.

    Create a UIScrollView.

    Add the view you want to scroll to the UIScrollView (as a subview).

    Then set the content size of the scrollview.

    Then set the directional lock.

    Done.

    Note, it's ill-advised to give you the code as then you don't learn anything. If you think you'll still learn if we give you the code, then hilight the text below.

    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame;

    [scrollView addSubview:aViewThatYouCreated]

    [scrollView setContentSize:CGSizeMake(the view you created's width, the view you created's height)];

    [scrollView setDirectionalLockEnabled:YES];

    [self.view addSubview:scrollView]; //or [self setView:scrollView]; depending on how your program works.
     
  7. thread starter macrumors newbie

    Joined:
    Mar 26, 2009
    #7
    i could not do this till now

    hi plz send me code i really need it ...i have written code for the same but it does not work...
     
  8. macrumors regular

    Joined:
    Apr 9, 2009
    #8
    if you can't do it, you should go back to learn the basics of Objective C
     
  9. macrumors regular

    Joined:
    Jun 10, 2008
    #9
    hi plz send me $25,000 i really need it.

    Is that how things work? I just say "plz i really need it", and it just ... happens? Damn, I've been doing it wrong all these years.
     

Share This Page