【发布时间】:2014-05-25 16:45:32
【问题描述】:
我有一个应用程序,我一直在为明显糟糕的教程而苦苦挣扎,并且在之前的帖子中撕毁了一个新的应用程序,所以有点担心再次发布。对不起,我总是会边做边学。
无论如何,我的登录、注册和其他功能都运行良好。我只是在使用 AVFoundation 进行条形码扫描时遇到了麻烦。我设置了我的流程去
(来源:leaguelaunch.com)
按钮单击 HomeViewController 以在扫描后将其推送到 ScanResultsViewController。
ScanResultsViewController 将发送 JSON 发布数据并呈现响应,但由于我遇到的错误,我这里什么都没有。我在这里只有这段代码可以直接展开到 HomeViewController 而不必推回 (BarcodeView) 然后推回 (HomeView)
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(back)];
self.navigationItem.hidesBackButton = YES;
self.navigationItem.leftBarButtonItem = item;
NSLog(@"Made it to Success!!!");
}
-(void)back{
[self performSegueWithIdentifier:@"unwindToHomeResult" sender:self];
}
如您所见,它可以工作,但它可以工作一次,也可以工作 10 次,然后我得到错误。
2014-05-25 12:11:32.378 selfcheckin[3344:60b] QR Code = {"stop_id":"3","event_id":"1"}
2014-05-25 12:11:32.801 selfcheckin[3344:60b] StopReading Called
2014-05-25 12:11:32.812 selfcheckin[3344:60b] Made it to Success!!!
2014-05-25 12:11:42.615 selfcheckin[3344:60b] QR Code = {"stop_id":"3","event_id":"1"}
2014-05-25 12:11:43.322 selfcheckin[3344:60b] StopReading Called
2014-05-25 12:11:43.334 selfcheckin[3344:60b] Made it to Success!!!
2014-05-25 12:11:50.850 selfcheckin[3344:60b] QR Code = {"stop_id":"3","event_id":"1"}
2014-05-25 12:11:51.296 selfcheckin[3344:60b] StopReading Called
2014-05-25 12:11:51.308 selfcheckin[3344:60b] Made it to Success!!!
2014-05-25 12:11:51.349 selfcheckin[3344:60b] QR Code = {"stop_id":"3","event_id":"1"}
2014-05-25 12:11:51.352 selfcheckin[3344:60b] StopReading Called
2014-05-25 12:11:51.370 selfcheckin[3344:60b] nested push animation can result in corrupted navigation bar
2014-05-25 12:11:51.759 selfcheckin[3344:60b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2014-05-25 12:11:51.851 selfcheckin[3344:60b] Unbalanced calls to begin/end appearance transitions for <ScanResultsViewController: 0x14e86570>.
所以我的主要问题是如何从 ResultsView 回到 HomeView。我很想只使用 NavigationController ,看看我是否可以不用。关于我可能出错的地方或正确方法的任何指示
谢谢
【问题讨论】:
-
您发布的代码中没有任何内容会导致此问题。您是否在主视图控制器的 viewWillAppear 或 viewDidAppear 方法中有任何代码可以开始转换到另一个控制器?此外,错误提到了嵌套的推送动画,但展开转场不应该使用推送,因此您应该描述如何设置展开转场。
-
再次阅读您的日志后,看起来问题可能出在 BarCodeViewController 中。 ScanResultsViewController 中的 ViewDidLoad 被多次调用,这意味着您正在创建该视图控制器的多个实例,并且可能是您试图在另一个推送发生的同时展开。如果没有看到 BarcodeViewController 中导致推送到 ScanResultsViewController 的代码,很难判断发生了什么。
标签: ios uinavigationcontroller segue uistoryboardsegue