Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.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 “展开”segue可以使用按钮,但不能以编程方式使用-为什么?_Ios_Objective C_Xcode_Segue_Master Detail - Fatal编程技术网

Ios “展开”segue可以使用按钮,但不能以编程方式使用-为什么?

Ios “展开”segue可以使用按钮,但不能以编程方式使用-为什么?,ios,objective-c,xcode,segue,master-detail,Ios,Objective C,Xcode,Segue,Master Detail,我对Objective C和Xcode没有一个好的开始-这是我第二次在一个简单的项目中来这里寻求帮助-令人尴尬 我的主(班)视图控制器加载一个细节(飞行员)视图控制器,该控制器依次加载第三个视图控制器(SelectNewPilot)和一个模式序列。这个很好用。如果按下SelectNewPilot(modal)视图上的cancel(取消)按钮,它将展开到Pilot(detail)视图控制器。在Pilot view控制器中,我有以下代码: - (IBAction)unwindToList:(UISt

我对Objective C和Xcode没有一个好的开始-这是我第二次在一个简单的项目中来这里寻求帮助-令人尴尬

我的主(班)视图控制器加载一个细节(飞行员)视图控制器,该控制器依次加载第三个视图控制器(SelectNewPilot)和一个模式序列。这个很好用。如果按下SelectNewPilot(modal)视图上的cancel(取消)按钮,它将展开到Pilot(detail)视图控制器。在Pilot view控制器中,我有以下代码:

- (IBAction)unwindToList:(UIStoryboardSegue *)segue
{
    UIViewController *source = [segue sourceViewController];
    if([source isKindOfClass:[Mz0SelectNewPilotViewController class]])
    {
        if ([(Mz0SelectNewPilotViewController *)source pilot] == nil)
        {
            NSLog(@"We cancelled selecting a new pilot");
            [self performSegueWithIdentifier:@"Unwind" sender:self];
        }
        else
        {
            NSLog(@"We selected %@", [[(Mz0SelectNewPilotViewController *)source pilot] name]);
        }
    }
}
因此,如果在SelectNewPilot(modal)控制器中未选择任何内容(即已取消),则飞行员控制器会自动将其进一步解回到班长(master)控制器。这会产生以下错误:

2014-03-13 00:45:07.578 Squad Builder[3149:70b] *** Assertion failure in -[UINavigationController popToViewController:transition:], /SourceCache/UIKit_Sim/UIKit-2935.120.3/UINavigationController.m:4886
2014-03-13 00:45:07.581 Squad Builder[3149:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'
*** First throw call stack:
(
    0   CoreFoundation                      0x01b629e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x018e28e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01b62848 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x014c20de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x006edbe0 -[UINavigationController popToViewController:transition:] + 302
    5   UIKit                               0x006edaad -[UINavigationController popToViewController:animated:] + 56
    6   UIKit                               0x006e633f __90-[UINavigationController segueForUnwindingToViewController:fromViewController:identifier:]_block_invoke + 142
    7   UIKit                               0x00b197ac -[UIStoryboardSegue perform] + 35
    8   UIKit                               0x00c7d623 -[UIStoryboardUnwindSegueTemplate _perform:] + 554
    9   UIKit                               0x00b090b7 -[UIStoryboardSegueTemplate perform:] + 115
    10  libobjc.A.dylib                     0x018f4880 -[NSObject performSelector:withObject:withObject:] + 77
    11  UIKit                               0x005a67f9 -[UIApplication sendAction:to:from:forEvent:] + 108
    12  UIKit                               0x008938bf -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
    13  libobjc.A.dylib                     0x018f4880 -[NSObject performSelector:withObject:withObject:] + 77
    14  UIKit                               0x005a67f9 -[UIApplication sendAction:to:from:forEvent:] + 108
    15  UIKit                               0x005a6785 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    16  UIKit                               0x006a7fe1 -[UIControl sendAction:to:forEvent:] + 66
    17  UIKit                               0x006a83d6 -[UIControl _sendActionsForEvents:withEvent:] + 577
    18  UIKit                               0x006a7653 -[UIControl touchesEnded:withEvent:] + 641
    19  UIKit                               0x005e621d -[UIWindow _sendTouchesForEvent:] + 852
    20  UIKit                               0x005e6e11 -[UIWindow sendEvent:] + 1117
    21  UIKit                               0x005b8a32 -[UIApplication sendEvent:] + 242
    22  UIKit                               0x005a2793 _UIApplicationHandleEventQueue + 11455
    23  CoreFoundation                      0x01aebf7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    24  CoreFoundation                      0x01aeb90b __CFRunLoopDoSources0 + 235
    25  CoreFoundation                      0x01b089ae __CFRunLoopRun + 910
    26  CoreFoundation                      0x01b081d3 CFRunLoopRunSpecific + 467
    27  CoreFoundation                      0x01b07feb CFRunLoopRunInMode + 123
    28  GraphicsServices                    0x03a175ee GSEventRunModal + 192
    29  GraphicsServices                    0x03a1742b GSEventRun + 104
    30  UIKit                               0x005a53db UIApplicationMain + 1225
    31  Squad Builder                       0x0000a6bd main + 141
    32  libdyld.dylib                       0x021ad701 start + 1
)
如果我把这行注释掉 [self-PerformsgueWithIdentifier:@“展开”发送方:self]; 然后一切正常,你只需按下飞行员控制器上的“取消”按钮,就可以回到班长那里。我的问题是,为什么当您使用按钮触发时(从飞行员到小队)展开序列会起作用,而当以编程方式调用时(这是同一个展开序列,我只是将一个标识符应用于cancel按钮使用的序列)却不起作用

班长控制器中的unwindToList方法已完成,因此我不确定调用了什么导致错误。是什么让segue想做点什么?故事板上的场景在哪里

班长的解卷列表方法如下(两个NSLog输出都出现在错误之前):


更新:在开始打印输出之前,我刚刚注意到另一个错误(以及最后一个错误):

对开始/结束外观转换的不平衡调用

这是因为它试图放松得太快了吗?有没有办法告诉它,在第一次放松(从SelectNewPilot到Pilot)完成之前,不要从一名飞行员到另一名飞行员放松?

在故事板上仔细检查你的序列名称<代码>NSLog(@“%@”,segue)可能很有启发性。segue必须工作-团队中unwindToList中的NSLog命令都已完成,因此segue正在到达那里,它只是尝试弹出一些东西,但当由情节提要中的按钮触发时,它不会这样做。编辑:刚刚用NSLog确认-这是正确的。在开始打印输出之前,我刚刚注意到另一个错误:开始/结束外观转换的调用不平衡,这是因为它尝试过快地释放吗?我有没有办法告诉它在第一次放松(从选择新飞行员到飞行员)完成之前不要从一个飞行员到另一个飞行员放松?
- (IBAction)unwindToList:(UIStoryboardSegue *)segue
{
    NSLog(@"Unwound to Squad");
    Mz0PilotViewController *source = [segue sourceViewController];
    Mz0Card *pilot = [source pilot];
    if ([pilot isKindOfClass:[Mz0Card class]])
    {
        NSLog(@"Adding new pilot: %@", [pilot name]);
        if(![_testData containsObject:pilot])
        {
            [_testData addObject:pilot];
            [self.tableView reloadData];
        }
    }
    NSLog(@"Finished unwinding to Squad");
}
Unbalanced calls to begin/end appearance transitions for <Mz0SquadViewController: 0x8dc8720>