PDA

View Full Version : scrolling in both direction???




anuroop
May 1, 2009, 02:04 PM
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



BlackWolf
May 1, 2009, 02:09 PM
I'd try a UIScrollView

Niiro13
May 1, 2009, 02:26 PM
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.

anuroop
May 3, 2009, 05:53 AM
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

BlackWolf
May 3, 2009, 08:22 AM
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

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/library/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html

Niiro13
May 3, 2009, 12:07 PM
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

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.

anuroop
May 22, 2009, 02:28 PM
hi plz send me code i really need it ...i have written code for the same but it does not work...

BlackWolf
May 22, 2009, 07:15 PM
hi plz send me code i really need it ...i have written code for the same but it does not work...

if you can't do it, you should go back to learn the basics of Objective C

kalimba
May 22, 2009, 07:57 PM
hi plz send me code i really need it ...i have written code for the same but it does not work...

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.