iOS   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – UITableView&Controller为我提供了空表视图大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我有一个应用程序(导航控制器),其中第二个控制器是一个表视图控制器.我能够通过segue发送我所需的数据,但无法以编程方式更新tableview中的条目. 我是IOS的新手. 这是我的头文件 #import <UIKit/UIKit.h> @interface HCIResultListViewController : UITableViewController @property (stron
我有一个应用程序(导航控制器),其中第二个控制器是一个表视图控制器.我能够通过segue发送我所需的数据,但无法以编程方式更新tableview中的条目.

我是IOS的新手.

这是我的头文件

#import <UIKit/UIKit.h>
@interface HCIResultListViewController : UITableViewController

@property (strong,nonatomiC) NSMutableDictionary *resultList;
@property (strong,nonatomiC) IBOutlet UITableView *tableListView;

@end

这是我的实现文件.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    #warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"HelloCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reusEIDentifier:CellIdentifier];
}

cell.textLabel.text = @"Hello";

// Configure the cell...

return cell;
}

谁能告诉我如何使用tableview&控制器?

我确实经历了几个文档和示例,但实际上无法理解

解决方法

您需要指定表视图的行和节数.像这样.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    #warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [sourceData Count]//i.e.,10;
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath
    {
    static NSString *CellIdentifier = @"HelloCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reusEIDentifier:CellIdentifier];
    }

    cell.textLabel.text = @"Hello";

    // Configure the cell...

    return cell;
    }

大佬总结

以上是大佬教程为你收集整理的ios – UITableView&Controller为我提供了空表视图全部内容,希望文章能够帮你解决ios – UITableView&Controller为我提供了空表视图所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。