让我的代表“工作”有些困难。
当ClassA通过UINavigationController将ClassB推送到堆栈时,它可以工作,但是当ClassB被不同的ClassC推送时,ClassB不会调用委托方法(在ClassA中)。
ClassA中的此方法有效:
- (void)openViewController:(NSString *)title:(int)dataType:(NSArray *)currentData {
ClassB *nextController = [[ClassB alloc] initWithNibName:@"ClassBView" bundle:nil];
nextController.delegate = self;
nextController.title = title;
nextController.dataType = dataType;
nextController.currentData = currentData;
nextController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextController animated:YES];}
如何从ClassC获得此方法,以正确指定ClassA作为ClassB的委托???
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ClassB *nextController = [[ClassB alloc] initWithNibName:@"ClassBView" bundle:nil];
nextController.delegate = ??????????
nextController.title = [self.tableData objectAtIndex:indexPath.row];
nextController.dataType = self.dataType;
nextController.currentData = [NSArray arrayWithArray:[self.dictionary objectForKey:[self.tableData objectAtIndex:indexPath.row]]];
nextController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextController animated:YES];}
感谢任何帮助。欢呼声。
答案 0 :(得分:0)
我想知道更多关于应用程序中的视图控制器层次结构会有所帮助,但听起来你需要在ClassC中添加一个可以传递给ClassB的ClassA引用。所以(在ClassC中)nextController.delegate = self.ClassARef