Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

anuroop

macrumors newbie
Original poster
Mar 26, 2009
4
0
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
 
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.
 
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
 
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/l...IScrollView_Class/Reference/UIScrollView.html
 
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.
 
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...
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.