ios, scrolling screen with a few objects without zooming

百般思念 提交于 2019-12-25 04:59:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!