我以编程方式创建了一个 UITableView 并且发现它不会滚动。这是我第一次以编程方式而不是通过 Interface Builder 创建 UITableView。我需要以编程方式设置一些属性以使我的视图滚动吗?我尝试过 setBounces、setScrollEnabled、setAlwaysBounceVertical,但似乎没有任何效果。任何想法将不胜感激!谢谢!
示例代码:
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
CGFloat height = (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) ? 460 : 300;
feed = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 44.0f, self.bounds.size.width, height - 44.0f)];
[feed setSeparatorColor:[UIColor colorWithRed:38.0f/255.0f green:43.0f/255.0f blue:63.0f/255.0f alpha:1.0f]];
[feed setBackgroundColor:[UIColor colorWithRed:48.0f/255.0f green:53.0f/255.0f blue:73.0f/255.0f alpha:1.0f]];
[feed setDataSource:self];
[feed setDelegate:self];
[feed setHidden:YES];
[feed setBounces:YES];
[feed setScrollEnabled:YES];
[feed setAlwaysBounceVertical:YES];
[feed setDelaysContentTouches:YES];
[self addSubview:feed];