Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIToolbar在关闭ModalViewController后返回视图时显示间隙_Iphone - Fatal编程技术网

Iphone UIToolbar在关闭ModalViewController后返回视图时显示间隙

Iphone UIToolbar在关闭ModalViewController后返回视图时显示间隙,iphone,Iphone,当按下infobutton以显示Modalviewcontroller并且当退出Modalviewcontroller以返回视图时,从显示视图的Mainviewcontroller按下按钮。加载视图后,UIToolbar显示从底部开始的间隙,间隙为UIToolbar高度 - (void)displayviewsAction:(id)sender { self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bound

当按下
infobutton
以显示
Modalviewcontroller
并且当退出
Modalviewcontroller
以返回视图时,从显示视图的
Mainviewcontroller
按下按钮。加载视图后,
UIToolbar
显示从底部开始的间隙,间隙为
UIToolbar
高度

- (void)displayviewsAction:(id)sender
{
   self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];

[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

   PageOneViewController *viewController = [[[PageOneViewController alloc] init]autorelease];

   [self.view addSubview:viewController.view];

   [self.view addSubview:toolbar];

}

- (void)modalViewAction:(id)sender

{
ModalViewController *controller = [[ModalViewController alloc] init];

controller.delegate = self;

UINavigationController *navigationController = [[UINavigationController alloc]
                                                initWithRootViewController:controller];
navigationController.navigationBar.tintColor = [UIColor brownColor];

controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:navigationController animated:YES];

[navigationController release];

}
任何人都知道如何修复它


谢谢您的帮助。

您的问题可能来自以下线路:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
如果不回显状态栏,将导致视图中出现间隙。 尝试在关闭模态视图控制器的方法中添加以下内容:

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

您的问题可能来自以下方面:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
如果不回显状态栏,将导致视图中出现间隙。 尝试在关闭模态视图控制器的方法中添加以下内容:

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

经过两天的努力,我终于找到了解决问题的办法。这很简单

我做了这些改变

- (void)displayviewsAction:(id)sender
{
 //self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];

//self.view.superview.frame = CGRectMake(0, 0, 320, 480);

PageOneViewController *viewController = [[[PageOneViewController alloc] init]autorelease];

viewController.view.frame = CGRectMake(0, 0, 320, 480);

[self.view addSubview:viewController.view];

[self.view addSubview:toolbar];
}

现在没有差距了。它工作得很好。

经过两天的努力,我的问题得到了解决。这很简单

我做了这些改变

- (void)displayviewsAction:(id)sender
{
 //self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];

//self.view.superview.frame = CGRectMake(0, 0, 320, 480);

PageOneViewController *viewController = [[[PageOneViewController alloc] init]autorelease];

viewController.view.frame = CGRectMake(0, 0, 320, 480);

[self.view addSubview:viewController.view];

[self.view addSubview:toolbar];
}

现在没有差距了。它工作正常。

您的MainViewController的级别是什么?它是UINavigationController还是UIViewController或UIAbbarController?你说“一旦视图加载,UIToolbar就会显示间隙”是在启动之后还是在取消模式之后?UIToolbar在模式显示视图或MainView中的何处?Mainviewcontroller是UIViewController。UIToolbar位于主视图控制器中。当应用程序启动时,当应用程序主视图控制器通过按下按钮显示视图时,一切正常;当您再次看到uitoolbar并按下信息按钮时,此视图显示modalviewcontroller;当此modalviewcontroller关闭并加载回视图时,uitoolbar显示从底部开始的间隙。您可能需要发布代码的某些部分,以查看到底发生了什么。似乎当您关闭视图时,工具栏的协调会发生变化,但很难这样说。我刚刚添加了当按下MainViewController中的按钮时显示的视图的代码。当您关闭modalView时,您是否将此方法称为“-(void)displayviewsAction:(id)sender”?MainViewController的类别是什么?它是UINavigationController还是UIViewController或UIAbbarController?你说“一旦视图加载,UIToolbar就会显示间隙”是在启动之后还是在取消模式之后?UIToolbar在模式显示视图或MainView中的何处?Mainviewcontroller是UIViewController。UIToolbar位于主视图控制器中。当应用程序启动时,当应用程序主视图控制器通过按下按钮显示视图时,一切正常;当您再次看到uitoolbar并按下信息按钮时,此视图显示modalviewcontroller;当此modalviewcontroller关闭并加载回视图时,uitoolbar显示从底部开始的间隙。您可能需要发布代码的某些部分,以查看到底发生了什么。似乎当您关闭视图时,工具栏的协调会发生变化,但很难说这样的话。我只是添加了从主视图控制器中按下按钮时显示的视图的代码。您是否再次调用此方法“-(void)displayviewsAction:(id)sender”,当您关闭modalView时?当第一次按按钮加载视图时,我也遇到了同样的问题,即uitoolbar显示间隙,并且当从视图加载时,modalviewcontroller显示状态栏和modalviewcontroller之间的间隙。这就是为什么我使用这条线,这条线解决了当按下按钮时,视图首先加载时的间隙,它也解决了modalviewcontroller的间隙。现在,当modalviewcontroller被解除时,我遇到的唯一间隙问题是。您检查过XIB文件中视图的大小了吗?如果没有状态栏,则应为320x480;如果有状态栏,则应为320x460。不使用interface builder。以前我使用两行self.view setFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];[[UIApplication sharedApplication]设置StatusBarHidden:YES with Animation:UIStatusBaranimationne];现在删除了这两个选项,并且只使用self.view.superview.frame=CGRectMake(0,0320480);它修复了加载视图和关闭modalviewcontroller时uitoolbar的间隙,但现在,当视图首先加载时,它显示状态栏和modalviewcontroller之间的间隙,关闭modalviewcontroller时也是如此。当第一次按下按钮时视图被加载时,我也遇到了同样的问题,即uitoolbar显示间隙和另外,当从视图加载时,modalviewcontroller还会显示状态栏和modalviewcontroller之间的间隙。这就是为什么我使用这条线,这条线解决了当按下按钮时,视图首先加载时的间隙,它也解决了modalviewcontroller的间隙。现在,当modalviewcontroller被解除时,我遇到的唯一间隙问题是。您检查过XIB文件中视图的大小了吗?如果没有状态栏,则应为320x480;如果有状态栏,则应为320x460。不使用interface builder。以前我使用两行self.view setFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];[[UIApplication sharedApplication]设置StatusBarHidden:YES with Animation:UIStatusBaranimationne];现在删除了这两个选项,并且只使用self.view.superview.frame=CGRectMake(0,0320480);它修复了加载视图和关闭modalviewcontroller时的uitoolbar间隙,但现在,首先加载视图时,它会显示状态栏和modalviewcontroller之间的间隙,关闭modalviewcontroller时也是如此。