【问题标题】:Dealing with unbalanced calls to begin/end appearance transition处理开始/结束外观转换的不平衡呼叫
【发布时间】:2012-12-19 17:18:17
【问题描述】:

我正在使用带有来自简单注释的标注的 mapView。我使用了下面的委托方法

- (void)mapView:(MKMapView *)_mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

    lbhProfileMapPoint *mp = (lbhProfileMapPoint *) view.annotation;
    NSLog(@"mp objectID: %@", mp.objectID);
    self.objectId = mp.objectID;
    [[lbhVariables sharedInstance] setMapViewChosenObjectId:self.objectId];

    //[self performSegueWithIdentifier:@"profileSegue" sender:self];
    lbhProfileViewController *pvc = [[lbhProfileViewController alloc] init];
    [pvc setObjectId:self.objectId];
    [self.navigationController pushViewController:pvc animated:NO];
}

它没有转到视图控制器,但一直在说

Unbalanced calls to begin/end appearance transitions for <lbhProfileViewController: 0x1f017ec0>.

实际上是 lbhProfileViewController,它通过其他视图控制器连接到我的故事板中。但是有了这个附件标注,我想手动调用它。如您所见,我有

//[self performSegueWithIdentifier:@"profileSegue" sender:self];

在代码中,但如果我改用这个方法,它仍然会给我不平衡的调用。

【问题讨论】:

    标签: ios mkmapview segue viewcontroller


    【解决方案1】:

    如果你使用performSegueWithIdentifier:sender: 方法,你也应该使用prepareForSegue:sender: 方法。 prepareForSegue:sender: 方法中的代码将是这样的:

    -(void)prepareForSegue:(UIStoryBoardSegue*) segue sender:(id) sender
    {
         if([segue.identifier isEqualToString:@"profileSegue"]){
             lbhProfileViewController *pvc = [segue destinationViewController];
             [[segue destinationViewController]setObject:sender.objectId];
         }
    }
    

    同样要使用它,你需要一个 segue 直接从视图控制器连接到 lbhProfileViewController,调用 map 委托方法。

    【讨论】:

    • segue 应该直接从 VC 连接到 lbhProfileViewController 对吧?我不知道如何从标注按钮连接到destinationController
    • 哦!而且 profileViewController 有两个 ContainerViews ...仅供参考
    • profileViewController 是否有两个容器视图无关紧要。如果您启用了情节提要,则需要将带有 mapView 的 viewController 的 segue 连接到 profileViewController。这可以通过右键单击故事板中的 viewController 并将连接拖动到 profileViewController 来完成。另外,不要忘记为您创建的 segue 命名。
    【解决方案2】:

    我找到了答案。

    在 ViewDidDisappear 方法中,我在做一个 self.navigationController pop 方法,所以和 this 冲突了。

    但是是的,这有帮助,谢谢!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-30
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多