UITableView 只显示和界面等高,无法滚动到后面

iOS 码拜 9年前 (2015-10-13) 1192次浏览
UITableView 只显示前面几条,无法滚动到后面,也就是界面有多高,就显示那几条,事实上肯定不止,但没有滚动条?

其中界面是

@interface myViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, retain) NSArray *dataList; 

@property (nonatomic, retain) UITableView *tbl;

@end

– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

#warning Incomplete method implementation.

    // Return the number of rows in the section.

    return 500;//这里无论返回多大的数,都只能是前面几行显示。

}

解决方案:10分
应该是高度问题,但不清楚的是,即使显示不全也应该会显示滚动条的。还是先从设置高度这个地方调调

CGRect bounds=[UIScreen mainScreen].bounds;
UITableView *tbl2=[[UITableView alloc] initWithFrame:CGRectMake(bounds.orgin.x, 10 , bounds.size.width,bounds.size.heigth-10) style:UITableViewStylePlain];
解决方案:10分
table.scrollEnabled = YES;
table.showsVerticalScrollIndicator = YES;

试一下上面两个属性,看看是不是你设置为NO了

解决方案:10分
高度就是屏幕高度,你设高了view是装下了,但都在画面外面显示呢,view认为它都显示出来了当然就不滚动了。
解决方案:10分
只显示几行,说明你的数据源就只有几行数据,请检查你的原始数据(数组)。

一般在函数中应该像下面那样返回row, 而不是直接返回一个指定的数。 最好截个图出来看看。

– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

 {

        return [yourDataSourceArray count];

 } 


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明UITableView 只显示和界面等高,无法滚动到后面
喜欢 (0)
[1034331897@qq.com]
分享 (0)