我的应用程序使用 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.
发布评论
评论(2)
查看使用以下命令关闭模态视图控制器的代码块会很有帮助:
这对我来说看起来不太正确,因为如果您在委托方法实现中调用它,“self”将引用您的对象。如果您通过委托方法收到对其视图控制器的引用,请尝试使用它来关闭它。如果您尝试从自己的视图控制器中消除它,并且您正在运行 iOS 5.0,则需要使用presentingViewController 而不是parentViewController 进行引用,例如:
It would be helpful to see the code block where you dismiss the modal view controller with:
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.:
答案是系统抛出的异常
您正在尝试多次推送 UAProductDetailViewController 的同一个实例。您应该创建一个新实例并推送它。
The answer is in the exception thrown by the system
You are trying to push the same instance of UAProductDetailViewController multiple times. You should be creating a new instance and pushing that.