我有一个带有 NavBar 和 ToolBar 的简单项目。我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor whiteColor]];
[toolBar setBarStyle:UIBarStyleBlack];
[toolBar setTranslucent:YES];
addPhotoItem = [[UIBarButtonItem alloc] initWithTitle:@"Add photo" style:UIBarButtonItemStyleBordered target:self action:@selector(showActionSheet)];
NSArray *itemsArray = @[ addPhotoItem ];
[toolBar setItems:itemsArray];
[toolBar setFrame:CGRectMake(0.0f, self.view.frame.size.height-44.0f, self.view.frame.size.width, 44.0f)];
[self.view addSubview:toolBar];
[navBar setFrame:CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 44.0f)];
[navBar setBarStyle:UIBarStyleBlack];
[navBar setTranslucent:YES];
[self.view addSubview:navBar];
}
在我的工具栏中,我有一个按钮可以打开带有 2 个选项的 ActionSheet:从相机和库中获取图像。我的代码:
- (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType {
self.imagePicker.delegate = self;
self.imagePicker.sourceType = sourceType;
[self presentModalViewController:self.imagePicker animated:YES];
}
但是在关闭模态控制器后,我的父视图上升了 44pt(大约)。我该如何解决这个问题?