IOS开发之TableView

遇到的问题:

1、 loaded the "TableViewController" nib but didn't get a UITableView

TableViewController是继承UITableViewController的。xib文件继承TableViewController,所以xib可视视图下直接装载UITableView。出现这个错误的情况是因为我的TableView上一级时一个UIView。不然会出现以上找不到UITableView的错误。

        一般都是使用UIViewController,然后放UIVIew,然后放TableView,xib关联的时候,将输出口view关联到UIView上。

2、 TableView加载不了数据,cellForRowAtIndexPath不会被执行到。

因为UITableViewDataSource有两个必须实现的方法,如下。

@required

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

3、loaded the "TableViewController" nib but the view outlet was not set

view的outlet输出口没有设置,也就是view视图没有和ViewController 视图控制器(或File’s Owner)建立连接。 

4、this class is not key value coding-compliant for the key 

     将xib的class设为对应的viewcontroller类

posted on 2014-12-04 11:17  兔儿爷  阅读(123)  评论(0)    收藏  举报

导航