UIToolbar在解除ModalViewController后返回View时显示间隙

时间:2012-02-08 17:27:15

标签: iphone

从显示视图的Mainviewcontroller按下按钮,按下infobutton以显示Modalviewcontroller时以及当ModalViewController被取消后返回查看时,从该视图按下按钮。加载视图后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];

}

任何人都知道如何解决它。

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

你的问题可能来自这一行:

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

如果您未显示状态栏,则会导致视图出现间隙。 尝试在解除模态视图控制器的方法中添加它:

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

答案 1 :(得分:0)

经过2天的挣扎得到了我的问题的解决方案。这很简单。

我做了这些修改

- (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];
}

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