Ios 从其他方法更新UITableViewCell中的值

Ios 从其他方法更新UITableViewCell中的值,ios,objective-c,uitableview,tableviewcell,Ios,Objective C,Uitableview,Tableviewcell,我有一个方法叫 - (void)redeemOfferService { // in this method i want access OffersBoughtCellTableViewCell, how to access tableview cell here ? // want to update selected tableview cell values // here i am getting selected cell details in selecte

我有一个方法叫

- (void)redeemOfferService
{
  // in this method i want access OffersBoughtCellTableViewCell,
      how to access tableview cell here ?
  // want to update selected tableview cell values
  // here i am getting selected cell details in selectedOfferBoughtObj which 
     is actually NSObject in that i am having five string values  
     i want show that values in my tableview cell how can i ?
  //

}
上述方法正在从调用

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex 
{
    if(alertView.tag == 10)
    {
       if(buttonIndex == 0)
       {
        [self redeemOfferService];
       }
    }
}
当我点击tableview单元格时,这个方法正在调用

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIAlertView *logoutAlert = [[UIAlertView alloc]initWithTitle:@"Are you sure you want to redeem?" message:nil delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
    logoutAlert.tag  = 10;
    [logoutAlert show];
}

我知道有一种方法,我们可以通过按钮单击发送发件人,但我希望在上述场景中。

您肯定是在从某个
NSMutableArray
更新tableview,这意味着您正在用此数组填充tableview

在您的
ReceiveOfferService
方法中,在填充tableview的
NSMutableArray
中更改该对象的值。
然后调用
[self.tableviewName reloadData]

在类中使用全局变量nsindepath类型,并在选定的存储上存储选定的indepath

NSIndexPath *selectedIndexPath; //declare it as a global
在didSelect中指定选定值后

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
UIAlertView *logoutAlert = [[UIAlertView alloc]initWithTitle:@"Are you sure you want to redeem?" message:nil delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
logoutAlert.tag  = 10;
[logoutAlert show];
selectedIndexPath = indexPath;
}
在你的功能中,像这样改变

    - (void)redeemOfferService
{
     OffersBoughtCellTableViewCell * _selectedCell = [offersTableView cellForRowAtIndexPath:selectedIndexPath]; //Now Its your selected cell Try this . 

}

它可以正常工作,请重试一次,然后恢复到

您可以使用
UITableView
indexPathForSelectedRow
属性访问选定的indexPath

- (void)redeemOfferService
{
     OffersBoughtCellTableViewCell *selectedCell = (OffersBoughtCellTableViewCell *)[tableViewObject cellForRowAtIndexPath:offersTableView.indexPathForSelectedRow];
}

这将为您提供所选的
OffersBoughtCellTableViewCell

OffersBoughtCellTableViewCell这是我的单元格,offersTableView这是我的表格视图,您能解释一下我的UITableViewCell*\u selectedCell=[tableViewObject cellForRowAtIndexPath:selectedIndexPath]吗;像这样试试。。我更新了YUP..,我尝试过,但它给我的错误是“不兼容的指针类型初始化OffersBoughtCellTableViewCell*,表达式为UITableviewCell*”值暂时显示。。当我滚动时,更新的值没有从cellforrowattindexpath显示如何解决这个问题?@Shrikant Kankatti我使用您在其他答案的评论中给出的信息更新了答案,正如Jogendra.Com所说的那样..但是现在面临的是..值暂时显示在RedemptionOfferService方法中。。当我滚动时,更新的值没有显示它从cellforrowattindexpath显示如何修复此问题?您应该更改CelForRowatteIndexPath方法。滚动时,使用CellForRowatineXpath方法重用和更新所有单元格。我不知道你的更新条件。所以我的建议是保留一个包含第一个值的对象数组。然后在更新单元格时,更新对象的值。同时,当您将数据加载到cell时,您应该在CellForRowatineXpath方法中使用此对象。我遵循Jogendra.Com的说法。但是现在面临…暂时显示值。。当我滚动时,更新的值没有显示它在cellforrowattindexpath中的显示。如何解决这个问题?