【问题标题】:How to Set (TableView cellForRowAtIndexpath) activity in A Button?如何在 A Button 中设置 (TableView cellForRowAtIndexpath) 活动?
【发布时间】:2013-05-30 12:44:49
【问题描述】:

大家好,请告诉我如何将此代码操作设置为 UIButton 操作... 这是代码:

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

NSString *myIdentiFier=@"myIdentiFier";

myCell *cell=[tableView dequeueReusableCellWithIdentifier:myIdentiFier];

if(!cell){
    //cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myIdentiFier];
    NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"myCell" owner:self options:nil];
    for(id obj in nib){
        if([obj isKindOfClass:[myCell class]]){
            cell=(myCell *)obj;
            break;
        }
    }
}

NSDictionary *diction=(NSDictionary*)[content objectAtIndex:indexPath.row];
[cell.contentView setBackgroundColor:[UIColor orangeColor]];

cell.empID.text=[diction objectForKey:@"empid"];
cell.empName.text=[diction objectForKey:@"empname"];
cell.designation.text=[diction objectForKey:@"empdesignation"];
cell.teamName.text=[diction objectForKey:@"empteam"];

return  cell;

}

我想在我的按钮中设置上述操作..

- (IBAction)displayRecord:(id)sender {
}

请告诉我...

【问题讨论】:

  • 你在寻找什么
  • @Bhupesh 无论我的 tableview 方法在做什么,我都希望它应该通过按钮操作来完成..
  • 您想在表格视图中添加新单元格吗?为此,您需要在数据源中插入新条目,即 content 数组。完成后,致电[tableView reloadData]

标签: iphone ios ios6 ios4


【解决方案1】:

你可以打电话

[tableview reloadData]

比 cellForRowAtIndexPath 被调用。

【讨论】:

【解决方案2】:

你可以按照以下方式进行

- (IBAction)displayRecord:(id)sender {
           [yourTablename reloadData];
}

【讨论】:

  • 检查你的 tableView 框架
  • 不显示..点击后显示消失的数据.. :(
  • 取消注释这一行 cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myIdentiFier];
  • 你添加委托和数据源吗?
  • 查看此链接“mindfiresolutions.com/…
猜你喜欢
  • 2015-08-20
  • 2016-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-04
  • 2021-09-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多