PDA

View Full Version : Problem in scrolling a view




iphonejudy
Dec 18, 2008, 06:10 AM
Hi,

I use IB.


First i create a view and add some controls in the top and bottom.

I change the view to scrollview.

I need to display some labels in the middle of the view.

so i add a new view.

I need to scroll the view.

Here my code


IBOutlet UIScrollView *scroll;
IBOutlet UIView *view1;

@property(nonatomic,retain) UIScrollView *scroll;
@property(nonatomic,retain) UIView *view1;


[scroll addSubview:view1];
[scroll setScrollEnabled:YES];
[scroll setContentSize:CGSizeMake(200,200)];
scroll.showsVerticalScrollIndicator=YES;
scroll.showsHorizontalScrollIndicator=YES;


My problem is the view is not scrolled.
I could not see any scrollbar indicator.

What is the mistake i done?
Can anybody please tell me the solution?

Thanks
judy



jnic
Dec 18, 2008, 06:53 AM
Scrollbars will only appear when the scroll view's content size is larger than its frame. See https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/contentSize

iphonejudy
Dec 18, 2008, 07:06 AM
Scrollbars will only appear when the scroll view's content size is larger than its frame. See https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/contentSize


i changed the content size to
scroll.contentSize = CGSizeMake(scroll.frame.size.width *10, scroll.frame.size.height*10);
still i could not see scrollbars

jnic
Dec 18, 2008, 09:51 AM
From the documentation:

showsHorizontalScrollIndicator

[...]

The default value is YES. The indicator is visible while tracking is underway and fades out after tracking.

i.e. scrollbars will only be visible when you are scrolling.

iphonejudy
Dec 18, 2008, 11:57 PM
From the documentation:



i.e. scrollbars will only be visible when you are scrolling.



Thank you jinc.its working.