问题
I have screen w/ a few labels. Each of them might be from 1 to a dozen lines. So some times all content not to fit on screen so scrolling is necessary.
All seem to be easy and there are a lot of tutorials how to do it. But my problem that scrolling works only when I zoom in screen. Setting "contentSize" doesn't give any effect.
@interface OMSScroolViewController : UIViewController <UIScrollViewDelegate>
@property (strong, nonatomic) IBOutlet UIScrollView *scroll;
@property (strong, nonatomic) IBOutlet UILabel *label1;
@property (strong, nonatomic) IBOutlet UILabel *label2;
@end
and implementation
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
scroll.minimumZoomScale=1.0;
scroll.maximumZoomScale=1.0;
[scroll setContentSize:CGSizeMake(320, 1690)]; // constants for simplicity
scroll.delegate=self;
}
any suggestions?
thanks in advance.
回答1:
Although not technically required, I've never had UIScrollView to work properly without using a content view to wrap the scrollable content. Once you wrap all your labels in a single view, your code should work without issue.
来源:https://stackoverflow.com/questions/20277025/ios-scrolling-screen-with-a-few-objects-without-zooming