【发布时间】:2014-09-18 13:13:10
【问题描述】:
我正在尝试将 UILabel 添加到 UIScrollView。我按照this 教程中的步骤操作。但是由于某种原因,当我运行该应用程序时,该标签未显示在 scrollView 上。该应用程序包含一个带有两个文件(ViewController.h 和 ViewController.m)的故事板。在故事板中只有一个视图控制器,它是 ViewController 的自定义类。下面是我在 ViewController.m 的 ViewDidLoad 方法中的代码。
UILabel *testLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 150.0, 250.0)];
testLabel.numberOfLines = 0;
[testLabel sizeToFit];
testLabel.text = @"test";
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 568.0)];
[scrollView addSubview:testLabel];
我在当前的末尾尝试了以下代码行,但仍然没有帮助。
[testLabel release];
[scrollView release];
【问题讨论】:
-
将scrollView添加到视图`[self.view addSubview:scrollView];
标签: ios objective-c xcode uiscrollview uilabel