IOS-23-Xcode6.4里UITableView不显示的可能原因及解决办法

1.必需设置以下三个方法,返回不能为“0”,显示几“”数据:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

#warning Potentially incomplete method implementation.

    // Return the number of sections.

    return 1;

}


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

    return self.friends.count;

}



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

{

    static NSString *ID = @"ContactCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 

    //获取对应的好友

    XMPPUserCoreDataStorageObject *friend = self.friends[indexPath.row]; 

    cell.textLabel.text = friend.jidStr;  

    return cell;

}



2.有的不需要设置代理,有的需要设置代理才行,下面是设置代理:

.h文件:

#import <UIKit/UIKit.h>


@interface WCContactsViewController : UITableViewController<UITableViewDataSource,UITableViewDelegate>


@end



.m文件:

- (void)viewDidLoad {

    [super viewDidLoad];

    self.friendsTableView.dataSource = self;

    self.friendsTableView.delegate = self;


    //从数据库加载好友列表显示

    [self loadFriends];


    [self.friendsTableView reloadData];

}

    

    

    

    

    




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IOT_Elon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值