发布视图控制器

发布于 2024-12-20 07:21:02 字数 1871 浏览 0 评论 0 原文

我的应用程序使用 ARC,但我在使用某些不使用它的第三方软件时遇到了麻烦。 我可以通过在构建阶段设置 -fno-objc-arc 来克服这个问题。然而,我遇到了一个问题,一个 ViewController 使 pp 崩溃,因为它被调用了两次。

我将尝试解释...

在我自己的 TableView 中,我选择了一条带 Urban Airship 的 StoreFront 的行。 据我所知,它作为一个模态窗口出现。 它是一个 TableView,直接指向我在 TableView 中选择的项目的 DetailView。我购买该商品并开始下载。 我有一位来自 Urban Airship 的代表,他在我的 TableView 中告诉我该项目何时安全地放在手机上。我[自我解雇ModalViewControllerAnimated:是];我自己的 TableView 中该委托末尾的 UAStore 并取回我的 TableView。
一切都工作得很好。

当我选择要购买的新产品时,就会出现问题。 我一路进入 UA DetailView,但是一旦我点击“购买”按钮,应用程序就会崩溃。

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<UAProductDetailViewController: 0x3a35e0>)'

对我来说, UAProductDetailViewController 似乎没有发布。 Urban Airship 的实现文件位于库中,因此无法对其进行调整。 我尝试了很多不同的方法来离开这里。

    [[DataModel sharedModel] saveContext]; 
    [[self tableView] reloadData]; 

  //  LessonListViewController *lessonListVC = [[LessonListViewController alloc] initWithNibName:@"LessonListView" bundle:nil];
    UserData *UserData_Array = [dm.UserData_Array objectAtIndex:0];
 //   lessonListVC.courseID = UserData_Array.current_levelName;
 //   lessonListVC.lessonsArray = UserData_Array.current_level;
    NSLog(@"Current level name:%@",UserData_Array.current_levelName);
    NSLog(@"Lessons array:%@",UserData_Array.current_level);

  //  lessonListVC.navigationItem.hidesBackButton = YES;

   // [self.navigationController popToViewController:lessonListVC animated:YES];
   // [UAProductDetailViewController removeFromParentViewController];
    self.tabBarController.tabBar.hidden = NO;
    [self dismissModalViewControllerAnimated:YES];

但到目前为止还没有任何效果。 希望有人能遵循我有点混乱的描述并通过头发保存。

** 当我回到自己的 TableView 时,UADetailViews 的 viewDidUnload 中的 NSLog 调用不会被调用。

My app uses ARC and I've got into trouble with some third party software that doesn't use it.
I can get over that by setting -fno-objc-arc in the build phase. However I am left with a problem where one ViewController crashes the pp because it gets called twice.

I will try to explain...

In my own TableView I select a line which bring on Urban Airship's StoreFront.
It comes on as a Modal window, as far as I can see.
It's a TableView that directly get pointed to the DetailView of the item that I selected in my TableView. I buy the item and it starts downloading.
I have a delegate from Urban Airship that tells me in my TableView when the item is safely down on the phone. I [self dismissModalViewControllerAnimated:YES]; the UAStore at the end of that delegate in my own TableView and get my TableView back.
All working just fine.

The problem occurs when I select a new product to buy.
I get ll the way to the UA DetailView, but once I hit the "buy" button the app crashes.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<UAProductDetailViewController: 0x3a35e0>)'

To me it looks like the UAProductDetailViewController is not released. Urban Airship's implementation files are in a library, so they are not available to tweak.
I've tried many different things to get out of here.

    [[DataModel sharedModel] saveContext]; 
    [[self tableView] reloadData]; 

  //  LessonListViewController *lessonListVC = [[LessonListViewController alloc] initWithNibName:@"LessonListView" bundle:nil];
    UserData *UserData_Array = [dm.UserData_Array objectAtIndex:0];
 //   lessonListVC.courseID = UserData_Array.current_levelName;
 //   lessonListVC.lessonsArray = UserData_Array.current_level;
    NSLog(@"Current level name:%@",UserData_Array.current_levelName);
    NSLog(@"Lessons array:%@",UserData_Array.current_level);

  //  lessonListVC.navigationItem.hidesBackButton = YES;

   // [self.navigationController popToViewController:lessonListVC animated:YES];
   // [UAProductDetailViewController removeFromParentViewController];
    self.tabBarController.tabBar.hidden = NO;
    [self dismissModalViewControllerAnimated:YES];

But nothing has worked so far.
Hopefully someone can follow my somewhat mixed up description and save by hair.

** A NSLog call in the UADetailViews's viewDidUnload does not get called when I'm back to my own TableView.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好多鱼好多余 2024-12-27 07:21:02

查看使用以下命令关闭模态视图控制器的代码块会很有帮助:

[self dismissModalViewControllerAnimated:YES];

这对我来说看起来不太正确,因为如果您在委托方法实现中调用它,“self”将引用您的对象。如果您通过委托方法收到对其视图控制器的引用,请尝试使用它来关闭它。如果您尝试从自己的视图控制器中消除它,并且您正在运行 iOS 5.0,则需要使用presentingViewController 而不是parentViewController 进行引用,例如:

[[self presentingViewController] dismissModalViewControllerAnimated:YES];

It would be helpful to see the code block where you dismiss the modal view controller with:

[self dismissModalViewControllerAnimated:YES];

That doesn't look quite right to me, since if you're calling it in a delegate method implementation, "self" would refer to your object. If you're receiving a reference to their view controller through the delegate method, try using that to dismiss it. If you try to dismiss it from your own view controller, and you're running iOS 5.0, you need to be referencing using presentingViewController rather than parentViewController, e.g.:

[[self presentingViewController] dismissModalViewControllerAnimated:YES];
抚你发端 2024-12-27 07:21:02

答案是系统抛出的异常

reason: 'Pushing the same view controller instance more than once is not supported'

您正在尝试多次推送 UAProductDetailViewController 的同一个实例。您应该创建一个实例并推送它。

The answer is in the exception thrown by the system

reason: 'Pushing the same view controller instance more than once is not supported'

You are trying to push the same instance of UAProductDetailViewController multiple times. You should be creating a new instance and pushing that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文