scrollview不在xib文件滚动 [英] the scrollview is not scrolling at xib file

查看:77
本文介绍了scrollview不在xib文件滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone开发的新手。我在我的应用程序中添加了scrollview,并在scrollview中以图形方式添加了10个按钮。但当我运行时,滚动视图不滚动

I am new in iphone development.. I have added the scrollview in my app and added 10 buttons graphically inside the scrollview. but when I run the scrollview is not scrolling

我的代码如下:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [scrollview setContentSize:CGSizeMake(1500,50)];

    [scrollview setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:scrollview];
}


推荐答案

看起来你正在服用在xib中的scrollview。所以,你需要从你的代码中删除 [self.view addSubview:scrollview]; ,你可以直接在xib中设置该scrollview的属性,除了setContentSize(你需要设置)在.m文件中)。

It looks like you are taking scrollview in xib. So, you need to remove [self.view addSubview:scrollview]; from your code and you can directly set properties of that scrollview in xib except setContentSize(that you need to set in .m file).

或者如果你想手动创建scrollView,请从xib中删除并使用它:

Or if you want to create scrollView manually, remove from xib and use this:

UIScrollView * content = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[content setContentSize:CGSizeMake(width, height)];
//Here you can add those buttons to content view
[self.view addSubView:content];

这篇关于scrollview不在xib文件滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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