0

我有一个问题:当我选择行并获取行索引时,UIView会调用 new 。消失时UIView,行的当前索引为null ( 0x000000)。这是我的代码:

我声明 rowupdate 变量:

NSInteger rowupdate;

didSelectRowAtIndexPath():我得到行索引并推送UIView

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    DetailView *detailAlert;
    rowupdate = indexPath.row;
     detailAlert = [[DetailView alloc] init];
            [self.view addSubview:detailAlert];
            [detailAlert show];
            [detailAlert release];

           }
}

然后UIView消失,我打电话:

[resevFileName replaceObjectAtIndex:rowupdate withObject:memotext];

但在控制台打印 rowupdate 为 null (0x000000) 并且 resevFileName 数组也为 null (0x00000) 。有人有建议吗?谢谢

4

4 回答 4

0

如果我对您的答案的理解是正确的,那么我认为您需要在详细视图中使用当前选定的索引,对吗?

如果是这种情况,那么您只需要在详细视图中声明一个属性,例如:

@property(nonatomic,readwrite) NSInteger rowupdate;

并在您的 didSelectRowAtIndexPath 中:

  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
   DetailView *detailAlert=[[DetailView alloc] init];
    detailAlert.rowupdate = indexPath.row;
            [self.view addSubview:detailAlert];
            [detailAlert show];
            [detailAlert release];

           }
}
于 2013-07-19T06:47:33.633 回答
0

我认为当您将行声明为:

int rowUpdate

在 .h 文件中。

但也可以尝试:

static  int row;

在 .m 文件中。

于 2013-07-19T06:18:10.163 回答
0

将您的变量初始化为:

NSInteger rowupdate;

希望这可以帮助。

于 2013-07-19T06:15:21.287 回答
-1

NSInteger *rowupdate;应该NSInteger rowupdate;没有' * '

NSInteger是原始数据类型。

于 2013-07-19T06:11:14.590 回答