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