Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用动态内容在Interface Builder中创建UIScrollView_Ios_Uiscrollview - Fatal编程技术网

Ios 使用动态内容在Interface Builder中创建UIScrollView

Ios 使用动态内容在Interface Builder中创建UIScrollView,ios,uiscrollview,Ios,Uiscrollview,我是iOS开发领域的新手 我试图让UIScrollView控件正常工作,遇到了以下问题: 我按照这个问题的答案中列出的步骤进行操作,一切都按照我的要求进行。但是,这似乎创建了一个静态大小的滚动视图。我真正想要的是一个动态大小的视图,可以滚动也可以不滚动。例如,我在viewDidLoad方法中设置文本和行数,而不是带按钮的视图,而是放置一个标签。包含标签的视图设置为静态大小,因此滚动查看器不会尝试滚动,标签内容会溢出页面 我缺少什么?您需要设置卷轴的内容大小 CGPoint controlsCe

我是iOS开发领域的新手

我试图让UIScrollView控件正常工作,遇到了以下问题:

我按照这个问题的答案中列出的步骤进行操作,一切都按照我的要求进行。但是,这似乎创建了一个静态大小的滚动视图。我真正想要的是一个动态大小的视图,可以滚动也可以不滚动。例如,我在viewDidLoad方法中设置文本和行数,而不是带按钮的视图,而是放置一个标签。包含标签的视图设置为静态大小,因此滚动查看器不会尝试滚动,标签内容会溢出页面


我缺少什么?

您需要设置卷轴的内容大小

CGPoint controlsCenter = ViewBottom.center;
if(Pointsvalue > 5)
{
controlsCenter.y += txtFldFrame1.frame.origin.y+20;
ViewBottom.center = controlsCenter;

[ScrollLag addSubview:ViewBottom];
}

[ScrollLag setContentSize:(CGSizeMake(0, controlsCenter.y+100))];

确保您的标签高度在输入文本时发生更改……

我对原始问题的评论中的URL为我提出的问题提供了解决方案。

我现在正在处理的项目中有一个动态大小的UIScrollView。这就是我所做的:

self.myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 250, 748)];
[self.myScrollView setBackgroundColor:[UIColor blackColor]];
int heightCounter = 10;

UIButton *newButton = [UIButton buttonWithType:UIButtonTypeCustom];
newButton.frame = CGRectMake(10, heightCounter, 200, 40);
[newButton setBackgroundColor:[UIColor clearColor]];
[newButton addTarget:self action:@selector(someMethod:) forControlEvents:UIControlEventTouchUpInside];
[newButton setTitle:@"ButtonTitle" forState:UIControlStateNormal];
[newButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.myScrollView addSubview:newButton];
heightCounter += 50;

// add additional items to the myScrollView and remember to increase the heightCounter

self.myScrollView.contentSize = CGSizeMake(250, heightCounter);
self.myScrollView.scrollEnabled = YES;
[self.view addSubview:self.myScrollView];

自动调整内容视图出口大小的一种方法是实现其功能,您可能还需要手动调用。请发布您迄今为止尝试过的内容,您的问题不是自我解释发布在以下问题上的答案是我想要的: