Ios UINavigationBar在presentViewController上消失:动画:完成
一周的大部分时间里,我都在拼命想弄清楚这个错误到底是怎么回事,但我什么也弄不清楚。我已经阅读了所有关于苹果开发者的view controller文档,在这里浏览了无数的文章,等等 我有3个视图控制器:一个基本视图控制器,一个图像编辑控制器(允许用户放大/平移图像,然后按OK,在范围内保存图像,通过委托方法将图像返回基本视图,并将其推送到最后一个视图控制器),最后是一个大的PictureViewController,用户可以在其中与保存的图像进行交互 从基本视图控制器调用presentViewController:animated:completion时,导航栏会出现一秒钟,然后消失。我已经完全删除了最终视图控制器,因此它只显示一个与首次创建视图控制器时相同的空白屏幕,但导航栏仍然消失,因此我知道它不是视图控制器编码中的内容 以下是来自图像编辑控制器(包含在基本视图控制器中)的代理: 接下来,在基本视图控制器的VIEWWILLEXPECT方法中,我检查用于切换序列的标志:Ios UINavigationBar在presentViewController上消失:动画:完成,ios,iphone,objective-c,Ios,Iphone,Objective C,一周的大部分时间里,我都在拼命想弄清楚这个错误到底是怎么回事,但我什么也弄不清楚。我已经阅读了所有关于苹果开发者的view controller文档,在这里浏览了无数的文章,等等 我有3个视图控制器:一个基本视图控制器,一个图像编辑控制器(允许用户放大/平移图像,然后按OK,在范围内保存图像,通过委托方法将图像返回基本视图,并将其推送到最后一个视图控制器),最后是一个大的PictureViewController,用户可以在其中与保存的图像进行交互 从基本视图控制器调用presentViewCo
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (BPVCFlag)
{
BPVCFlag = NO;
BigPictureViewController *bpvc = [[BigPictureViewController alloc] init];
UIStoryboardSegue *seg = [[UIStoryboardSegue alloc] initWithIdentifier:@"pushitrealgood" source:self destination:bpvc];
[self prepareForSegue:seg sender:self];
}
}
最后,prepareForSegue方法:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSString *id = [segue identifier];
if ([id hasPrefix:@"pushit"]){
BigPictureViewController *bpvc = segue.destinationViewController;
bpvc.imageFromLibrary = theImage;
[self presentViewController:bpvc animated:YES completion:nil];
}
}
我试着从self.navigationController等处演示它,如果我使用它,我可以让它与不同的导航控制器保持一致
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:bpvc];
[self.navigationController presentViewController:navCon animated:YES completion:nil];
但这似乎是一种非常老套的方法,实际上并没有解决问题,只是绕过了问题
对不起,这是一堵文字墙,但我宁愿彻底,也不愿让人们蒙在鼓里
TL;在presentViewController上,导航栏会弹出一秒钟,然后消失~
提前感谢您的帮助/提示 试试这个
BigPictureViewController *bpvc = segue.destinationViewController;
bpvc.imageFromLibrary = theImage;
UINavigationController *navcont = [[UINavigationController alloc] initWithRootViewController:bpvc];
[self presentModalViewController:navcont animated:YES];
试试这个
BigPictureViewController *bpvc = segue.destinationViewController;
bpvc.imageFromLibrary = theImage;
UINavigationController *navcont = [[UINavigationController alloc] initWithRootViewController:bpvc];
[self presentModalViewController:navcont animated:YES];
你的“黑客”解决方案实际上是正确的解决方案。调用presentViewController:animated:completion:
时,显示视图控制器的导航控制器将不再可见。可以说,您正在添加一个新层
如果希望显示的视图控制器(您的BigPictureViewController
)位于导航控制器中,则必须创建一个新的导航控制器,并将新的视图控制器作为根控制器传递。然后你展示导航控制器
所以你想要这个:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSString *id = [segue identifier];
if ([id hasPrefix:@"pushit"]) {
BigPictureViewController *bpvc = segue.destinationViewController;
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:bpvc];
bpvc.imageFromLibrary = theImage;
[self presentViewController:navCon animated:YES completion:nil];
}
}
你的“黑客”解决方案实际上是正确的解决方案。调用presentViewController:animated:completion:
时,显示视图控制器的导航控制器将不再可见。可以说,您正在添加一个新层
如果希望显示的视图控制器(您的BigPictureViewController
)位于导航控制器中,则必须创建一个新的导航控制器,并将新的视图控制器作为根控制器传递。然后你展示导航控制器
所以你想要这个:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSString *id = [segue identifier];
if ([id hasPrefix:@"pushit"]) {
BigPictureViewController *bpvc = segue.destinationViewController;
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:bpvc];
bpvc.imageFromLibrary = theImage;
[self presentViewController:navCon animated:YES completion:nil];
}
}
您正在演示一个BigPictureViewController-它是UINavigationController的子类吗?self.navigationController是唯一引用的,之前控制器对象是否初始化?您正在演示一个BigPictureViewController-它是UINavigationController的子类吗?self.navigationController是唯一引用的,之前控制器对象是否初始化?好的,非常感谢你!这是一种非常奇怪的解决问题的方法,但如果这是正确的方法,那么我会让我的头脑放松。干杯,好的,非常感谢!这是一种非常奇怪的解决问题的方法,但如果这是正确的方法,那么我会让我的头脑放松。干杯,伙计