xcode 嵌套推送动画可能会导致导航栏损坏多次警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11813091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
nested push animation can result in corrupted navigation bar multiple warning
提问by Rom.
I'm new in ios app developping and i'm having some trouble with multiple warnings.
我是 ios 应用程序开发的新手,我遇到了多个警告的问题。
I have a Navigation Controller that load a table view. From that table view one touch on a cell pushes a new VC (basically, the detail of the cell). And on that "detailView", when a certain button is pushed, another VC is pushed.
我有一个加载表视图的导航控制器。从那个表格视图中,对单元格的一次触摸会推动一个新的 VC(基本上是单元格的细节)。在那个“detailView”上,当按下某个按钮时,会按下另一个 VC。
I push the last VC with the following code :
我使用以下代码推送最后一个 VC:
- (IBAction)toMoreDetail:(id)sender
{
[self performSegueWithIdentifier:@"toMoreDetail" sender:self];
}
And when i do that, 2 warnings are poping :
当我这样做时,会弹出 2 个警告:
2012-08-05 02:25:41.842 appName[2145:f803] nested push animation can result in corrupted navigation bar
2012-08-05 02:25:42.197 appName[2145:f803] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
I didn't find any good answer so far. Maybe anyone can help me with this problem.
到目前为止我没有找到任何好的答案。也许任何人都可以帮助我解决这个问题。
Thanks :)
谢谢 :)
Edit : here is the code for the other segue :
编辑:这是另一个 segue 的代码:
From the TableList to the VC of detail (the segue start from the prototype cell and goes to the detail vc) :
从 TableList 到 detail 的 VC(segue 从原型单元开始并转到细节 vc):
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"toDetailEvent"])
{
NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
DetailEvent* detailEvent = [segue destinationViewController];
detailEvent.eventToDisplay = [listEvents objectAtIndex:selectedIndex];
}
}
回答by danqing
My guess would be your button is linked with the segue, so when you add an IBAction
on it, you trigger the segue twice.
我的猜测是你的按钮与 segue 链接,所以当你IBAction
在它上面添加一个时,你会触发 segue 两次。
If you go to your Storyboard and click on the segue, you should be able to see its origin and destination. Is its origin the entire view controller or just the button? You only need to manually performSegue
if the origin is the entire view controller. Can you try comment out your [self performSegueWithIdentifier:@"toMoreDetail" sender:self];
stuff to see if it will work?
如果您转到 Storyboard 并单击 segue,您应该能够看到它的起点和终点。它的起源是整个视图控制器还是按钮?performSegue
如果原点是整个视图控制器,您只需要手动。您可以尝试注释掉您的[self performSegueWithIdentifier:@"toMoreDetail" sender:self];
内容以查看它是否有效吗?
回答by Rob Aldcorn
It seem that if you use a storyboard and hook up your segue from the source vc to the destination vc and call the segue using didSelectRow you can not leave an else statement for a segue choice: This works:
似乎如果您使用故事板并将您的 segue 从源 vc 连接到目标 vc 并使用 didSelectRow 调用 segue 您不能为 segue 选择留下 else 语句:这有效:
if ((indexPath.row == 0 && indexPath.section == 0)) {
[self performSegueWithIdentifier:@"simpleLines" sender:self];
}
if ((indexPath.row == 0 && indexPath.section == 5)) {
[self openAppStore];
}
if (indexPath.section == 4) {
[self performSegueWithIdentifier:@"pushSettingsVC" sender:self];
}
This does not work:
这不起作用:
if ((indexPath.row == 0 && indexPath.section == 0)) {
[self performSegueWithIdentifier:@"simpleLines" sender:self];
}
if ((indexPath.row == 0 && indexPath.section == 5)) {
[self openAppStore];
}
else {
[self performSegueWithIdentifier:@"pushSettingsVC" sender:self];
}
You get a weird double push when using navigation controller. I do this every time I start a project and always forget why it happens. Next time I
使用导航控制器时,你会得到一个奇怪的双推。每次我开始一个项目时我都会这样做,但总是忘记它为什么会发生。下次我