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

sandeepac

macrumors newbie
Original poster
Jul 10, 2008
3
0
Cochin
Hi All

Is there any sample code for Scrollable UIView (which is a subview with some drawings inside).

I made a custom UIScrollView and made it the superview of my UIView.
But it is not working.

Regards
Sandeep
 

Shrunga

macrumors newbie
Aug 8, 2008
4
0
Scrollable UIView

Hi,

Im a newbie to Iphone programming and I too Im working on the same without any success.

Has anyone found a solution for this ?
If so kindly post some pointers..

Regards,
Shruga
 

PhilNash

macrumors newbie
Mar 20, 2008
2
0
Hi All
I made a custom UIScrollView and made it the superview of my UIView.

That's a good start. You'll also need to implement a UIScrollViewDelegate and at least the scrollViewDidScroll method on it.

You say it "doesn't work" - can you be any more specific?
Do you get content but it doesn't scroll?
Do you get no content?
Does it scroll but not zoom?
etc...
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
That's a good start. You'll also need to implement a UIScrollViewDelegate and at least the scrollViewDidScroll method on it.

A delegate is not required for UIScrollView. The only time you'll "need to implement" one is if you need to perform sometimes in one of the methods provided by the UIScrollViewDelegate protocol.

---

Most people forget to set the contentSize property properly when using a UIScrollView. Other than that, you aren't giving us any information with which to help you. "It's not working" is not going to get you any targeted answers.
 

seventoes

macrumors newbie
Feb 5, 2008
28
0
Hi All

Is there any sample code for Scrollable UIView (which is a subview with some drawings inside).

I made a custom UIScrollView and made it the superview of my UIView.
But it is not working.

Regards
Sandeep

Sounds like the same problem i had. Make sure you set the contentSize property of the scrollview. That's what fixed it for me.
 

Shrunga

macrumors newbie
Aug 8, 2008
4
0
Sounds like the same problem i had. Make sure you set the contentSize property of the scrollview. That's what fixed it for me.

Yes! :)
Here is what i did and it works perfectly fine for me now. Make sure that your custom view's frame is larger than scrollview's frame. This is what was stopping my scroller from getting displayed.
Thank you all.

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[MyView frame]];//(0,0,320,160)
scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

[MyView setFrame:CGRectMake (0, 0, 320, 170)];
MyView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
scrollView.contentSize = MyView.bounds.size;


scrollView.bounces = YES;
scrollView.bouncesZoom = YES;
scrollView.scrollEnabled = YES;
scrollView.minimumZoomScale = 0.5;
scrollView.maximumZoomScale = 5.0;
scrollView.delegate = self;

[scrollView addSubview: MyView];
[self.view addSubview:scrollView];

Thanks and Regards,
Shrunga
 

springframework

macrumors member
Mar 31, 2008
59
0
ok i figured out what was wrong.

i was doing this:

PHP:
innerview = [[UIView alloc] initWithFrame:CGRectZero];

is seems the frame needs to have its bounds set.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.