ios,带有几个对象的滚动屏幕而不缩放 [英] ios, scrolling screen with a few objects without zooming

查看:39
本文介绍了ios,带有几个对象的滚动屏幕而不缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带几个标签的屏幕.它们中的每一个可能是 1 到 12 行.因此有时所有内容都无法显示在屏幕上,因此需要滚动.

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.

一切似乎都很简单,而且有很多教程可以做.但是我的问题是只有当我放大屏幕时滚动才有效.设置contentSize"没有任何效果.

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

和实施

- (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;
}

有什么建议吗?

提前致谢.

推荐答案

虽然不是技术要求,但我从来没有让 UIScrollView 在不使用内容视图来包装可滚动内容的情况下正常工作.将所有标签包装在一个视图中后,您的代码应该可以正常工作.

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.

这篇关于ios,带有几个对象的滚动屏幕而不缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆