Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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 视图之间的索引值传输_Ios_Objective C - Fatal编程技术网

Ios 视图之间的索引值传输

Ios 视图之间的索引值传输,ios,objective-c,Ios,Objective C,这是我的TableViewController的didSelectRowatineXpath,选择单元格后,它将转到另一个viewController,即HistoryDetails 现在我在HistoryDetails类中有一个属性currentIndex,我将数据设置为该属性,即indexPath.row。但是在HistoryDetails.m中,我没有得到所选的索引值(总是得到0)。我的代码哪里有错 也许你是说 - (void)tableView:(UITableView *)tableV

这是我的TableViewController的
didSelectRowatineXpath
,选择单元格后,它将转到另一个
viewController
,即HistoryDetails

现在我在
HistoryDetails
类中有一个属性
currentIndex
,我将数据设置为该属性,即
indexPath.row
。但是在
HistoryDetails.m
中,我没有得到所选的索引值(总是得到0)。我的代码哪里有错

也许你是说

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

  UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

  UIViewController *storyViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"StoryViewController"];
  HistoryDetails *obj = [[HistoryDetails alloc]init];
  obj.currentIndex = indexPath.row;

  [self presentViewController:storyViewController animated:YES completion:nil]; 

}
实例化视图控制器标识符
返回请求的视图控制器。
您需要将实例化的控制器强制转换为自定义子类

也许你是说

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

  UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

  UIViewController *storyViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"StoryViewController"];
  HistoryDetails *obj = [[HistoryDetails alloc]init];
  obj.currentIndex = indexPath.row;

  [self presentViewController:storyViewController animated:YES completion:nil]; 

}
实例化视图控制器标识符
返回请求的视图控制器。

您需要将实例化的控制器强制转换为自定义子类

什么是历史详细信息?创建一个新对象:
HistoryDetails*obj=[[HistoryDetails alloc]init]
obj
storyViewController
(您显示的ViewController)之间有什么联系?可能是我弄错了。您能否告诉我如何通过点击单元格将数据发送到storyViewController(类:HistoryDetails)。
storyViewController
是一个
HistoryDetails
对象?您需要将数据传递到
storyViewController
。是否要在索引处而不是索引本身发送项目/对象?好的,让我清除
didSelectRowAtIndexPath
位于第一个
tableViewController
中。现在,如果我点击单元格,它将转到另一个
viewController
,其自定义类是
HistoryDetails
。现在我想将所选索引号发送到该视图。什么是确切的
HistoryDetails
?创建一个新对象:
HistoryDetails*obj=[[HistoryDetails alloc]init]
obj
storyViewController
(您显示的ViewController)之间有什么联系?可能是我弄错了。您能否告诉我如何通过点击单元格将数据发送到storyViewController(类:HistoryDetails)。
storyViewController
是一个
HistoryDetails
对象?您需要将数据传递到
storyViewController
。是否要在索引处而不是索引本身发送项目/对象?好的,让我清除
didSelectRowAtIndexPath
位于第一个
tableViewController
中。现在,如果我点击单元格,它将转到另一个
viewController
,其自定义类是
HistoryDetails
。现在我想将所选索引号发送到该视图。