点击按钮时改变tableview中其中一行的文本

qscool1987 qscool1987 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题,相关代码如下

//在按下该按钮时要求改变tableview其中一行的文本
- (IBAction)inputCMDEnter:(UIButton *)sender {
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell *cell = [tableCMDView cellForRowAtIndexPath:indexPath];
cell.textLabel.text = @"123";
}

//代理相关的函数
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return 15;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"COMMANDS";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
}

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

在connections inspecors中,已经将tableview的datasource和delegate关联到files owner了。
可是tableview中的文本一直没有改变,弄了一下午了,求解决方法
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
qscool1987
iOS 29,038 成员 12,459 内容