- 首页 > it技术 > >
//在cell中获取到cell所属的ViewController
- (AnchorMoreViewController *)parentViewController
{
for (UIView* next = [self superview];
next;
next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[AnchorMoreViewController class]]) {
return (AnchorMoreViewController *)nextResponder;
}
}
return nil;
}// 获取NavigationController中的某个VC
SingleTopicViewController *target = nil;
for (UIViewController * controller in self.navigationController.viewControllers) { //遍历
if ([controller isKindOfClass:[SingleTopicViewController class]]) { //这里判断是否为你想要跳转的页面
target = (SingleTopicViewController *) controller;
}
}
if (target) {
self.topicName = target.topicModel.title;
self.topid = target.topicModel.topid;
}
推荐阅读