如何使用故事板?
我正在尝试使用故事板 segue 而不是 didSelectRowAtIndex。
这就是我所拥有的,但此方法无法识别indexPath.row。我可以用其他方法来做同样的事情吗?
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
SpecificExerciseTableViewController *upcomingViewController = segue.destinationViewController;
if ([segue.identifier isEqualToString:@"Web"])
{
upcomingViewController.exerciseArray = [[self.muscleArray objectAtIndex:indexPath.row]objectForKey:@"exercises"];
upcomingViewController.muscleName = [[self.muscleArray objectAtIndex:indexPath.row]objectForKey:@"muscleName"];
}
}
I'm trying to use storyboards segue instead of didSelectRowAtIndex.
This is what I have, but this method does not recognize indexPath.row. Is there an alternative I can use to do the same thing?
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
SpecificExerciseTableViewController *upcomingViewController = segue.destinationViewController;
if ([segue.identifier isEqualToString:@"Web"])
{
upcomingViewController.exerciseArray = [[self.muscleArray objectAtIndex:indexPath.row]objectForKey:@"exercises"];
upcomingViewController.muscleName = [[self.muscleArray objectAtIndex:indexPath.row]objectForKey:@"muscleName"];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您将该 indexPath 作为 ivar,否则作用域中不存在此类变量。
如果您想获取 UITableView 中所选行的索引路径,请使用:
上面调整后的代码:
Unless you have that indexPath as an ivar, no such variable exists in the scope.
If you would like to get the indexPath for the selected row in a UITableView use:
The adjusted code for above:
的示例
这个技巧效果很好,下面是我如何使用它将解析的元素拉入网页视图.h 文件
.m 文件
This trick works fine,heres an example of how I used it to pull parsed elements into a web view
.h file
.m file