大家好,我正在创建一个 iPhone 应用程序。它使用 uitableview 并进入详细视图。
现在在详细视图上,我有一个滚动视图,所有数据(XML)都可以正常输入,每次都没有问题。
我的滚动视图中的 UILabel 确实使用正确的数据进行了更新,但是,它们不断在彼此之上添加子视图,以不断添加标签,这一切看起来都像胡说八道。
我已经尝试了一切来尝试删除子视图,例如:
for(UIView *subview in [scrollView subviews]) {
[subview removeFromSuperview];
}
和
[[scrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
所以我很困惑,我不知道发生了什么。有什么帮助吗?我一直在谷歌上搜索年龄和年龄,但一直在寻找不起作用的相同答案:(
任何可能对您有所帮助的网站的指示将不胜感激。
谢谢!
这是我在控制器中加载所有滚动视图和标签的内容:
- (void)viewDidAppear:(BOOL)animated {
// Create the scroll view for this view
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
scrollView.contentSize = CGSizeMake(320, 270);
[scrollView setFrame:CGRectMake(0, 198, 320, 170)];
// Do the labels for the text
UILabel *dates = [[UILabel alloc] initWithFrame:scrollView.bounds];
dates.textColor = [UIColor whiteColor];
dates.font = [UIFont boldSystemFontOfSize:12];
dates.text = round_date;
dates.tag = 1;
[dates setBackgroundColor:[UIColor clearColor]];
[dates setFrame:CGRectMake(10, 10, 280, 22)];
[scrollView addSubview:dates];
[dates release];
// Add the content to the main scrollview
[self.view addSubview:scrollView];
[scrollView release];
}