Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在viewController中重新加载tableView_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 在viewController中重新加载tableView

Ios 在viewController中重新加载tableView,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我在故事板上设置了一个viewcontroller,并在该视图控制器中插入了一个tableView。我想做一个[self.tableView重载数据]在viewDidLoad上,但它表示找不到属性tableView 以下是viewcontroller.m文件中我的tableView的代码: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSString *)tableV

我在故事板上设置了一个viewcontroller,并在该视图控制器中插入了一个tableView。我想做一个
[self.tableView重载数据]在viewDidLoad上,但它表示找不到属性tableView

以下是viewcontroller.m文件中我的tableView的代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section     {
    return @"Shared with";
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return activeUsers.count;
}

- (sharedUsersTable *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"sharedUser";

    sharedUsersTable *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[sharedUsersTable alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    NSDictionary *key = [activeUsers objectAtIndex:indexPath.row];
    NSString *name = [key objectForKey:@"shared_user_name"];
    NSString *email = [key objectForKey:@"email"];

    cell.textLabel.text = [NSString stringWithFormat:@"%@", name];
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", email];

    return cell;
}

我是否缺少一些特殊命令来调用不是TableViewCOntroller的视图控制器中的tableView?

您需要为
tableView
创建一个
IBOutlet
,并在此基础上调用
reloadData

这取决于您如何声明
UITableView


如果它是一个属性(
@property(非原子,强)UITableView*myTableView
),它将是
[self.myTableView reloadData]
。如果您将其声明为一个实例变量(
UITableView*\u myTableView
),那么它将是
[\u myTableView reloadData]

,您必须将tableview数据源和委托定义为self。。类似于
表。datasource=self

table.delegate=self
…您可以在viewdidload中执行此操作…但是如果您在某个地方下载了数据,那么您可以在下载的地方执行此操作并在那里重新加载表。请将委托和数据源分配给表,并在下载数据后重新加载tableview…。请创建一个属性,如
(@property(nonatomic,strong)UITableView*table)
,并在重新加载时使用self…

是否设置委托和数据源?恐怕没有。我到底在哪里定义这些?谢谢,应该可以。但是,视图没有加载数据。如果我的tableview被称为
sharedView
我应该如何修改上面的代码以使其正确呈现?我假设现在,我的代码没有定义正确的tableView。您必须分配委托和数据源。使用
tableView.datasource=self
tableView.delegate=self我到底在哪里定义这些?