view inside scrollView it is not moving
I have a UIScrollView
of size 320x412 and inside it an UIView
of size 280x277.But I tried for hours to make that View
move up and down when I 开发者_如何学编程drag it.If I replace the UIView
with a TextView
it is working...I can drag the TextView up and down inside the UIScrollView...but with the View it is not working.
This is how my xib file looks like.The black one is the View I want to make it move inside the UIScrolView.ANy idea why is this not working?
EDIT: I did this
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollView.contentSize = CGSizeMake(320,480);
scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
scrollView.bounces = YES;
scrollView.bouncesZoom = YES;
scrollView.scrollEnabled = YES;
scrollView.minimumZoomScale = 0.5;
scrollView.maximumZoomScale = 5.0;
scrollView.delegate = self;
//myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[scrollView addSubview:myView];
[myView release];
And still not working!
You need to set the content size of scrollview greater then scrollview frame height to make the scrollview to scroll vertically. You scrollview height is 412. Set content size, scrollview.contentSize = CGSizeMake(320, 430);
ALWAYS resize scrollview.contentSize .....
and not the scrollview.frame :===////
good luck! :=)
精彩评论