ios - 为什么我的UITableView没有填充注释 [英] ios - why does my UITableView not get populated with comments

查看:61
本文介绍了ios - 为什么我的UITableView没有填充注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView,在我的.h文件中声明如下:

I have a UITableView which is declared like this in my .h file:

@interface EnterInviteCodeController : UIViewController
@property (weak, nonatomic) IBOutlet UITableView *itemList;
@end

然后我在我的.m文件中声明它就像这样

And then I declare it like this in my .m file

#import "EnterInviteCodeController.h"

@interface EnterInviteCodeController ()
@property (nonatomic, retain) NSArray *items_array;
@end
@implementation EnterInviteCodeController
@synthesize itemList; // UITableView

但是当我尝试填充列表时,没有任何项目出现。这是我填充列表的方式。我对服务器进行远程调用以获取项目。然后当服务器返回数据时,我尝试这样做:

But when I try to populate the list, no items show up. Here is how I populate the list. I make a remote call to a server to get the items. And then when the server comes back with data, I try to do this:

                         items_array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
                         [self.itemList reloadData];

                         dispatch_sync(dispatch_get_main_queue(), ^{
                             [self.itemList reloadData];
                         });

但是数据没有显示出来。有谁知道我在这里缺少什么?

But the data does not show up. Would anyone know what I am missing here?

谢谢!

推荐答案

你需要实现的最低限度:

Bare minimum you need to implement:

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

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

并且说你实现了UITableViewDataSource。

and say you implement the UITableViewDataSource.

@interface EnterInviteCodeController : UIViewController <UITableViewDataSource>

还要确保将文件所有者设置为表的委托。

Also make sure you set the File Owner as the delegate for your table.

这篇关于ios - 为什么我的UITableView没有填充注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆