您的位置:首页 > 产品设计 > UI/UE

解决当把系统自带的UIImagePickerController 作为一个uiviewcontroller时有20像素间隙的问题

2013-12-15 12:11 986 查看
#pragma mark --
#pragma mark Methods
- (void)initImagePickerControllerInterface
{
    if (!_imagePickerController) {
        _imagePickerController = [[UIImagePickerController
alloc] init];
    }
    
    [_imagePickerController
setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [_imagePickerController
setDelegate:self];
    [_imagePickerController
setAllowsEditing:NO];
    [self
addChildViewController:_imagePickerController];
    [self.view
addSubview:_imagePickerController.view];
    if ([GNDevice
versionPermit:7
second:0]) {
        [[UIApplication
sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    } else {
        [[UIApplication
sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
    }
    
}

然后在delegate里写上

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if ([GNDevice
versionPermit:7
second:0]) {
        [[UIApplication
sharedApplication] setStatusBarHidden:NO];
        [[UIApplication
sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    } else {
//其实就是加了这个动画
        [UIView
animateWithDuration:0.4
animations:^{
            
            [[UIApplication
sharedApplication] setStatusBarHidden:YES];
            
        } completion:^(BOOL finished) {
            [[UIApplication
sharedApplication] setStatusBarHidden:NO];
        }];
    }
    
    
    UIView *custom = [[UIView
alloc] initWithFrame:CGRectMake(0,0,0,0)];
    UIBarButtonItem *btn = [[UIBarButtonItem
alloc] initWithCustomView:custom];
    [viewController.navigationItem
setRightBarButtonItem:btn animated:NO];
    viewController.title =
@"扫 一
扫";
    
    if ([GNDevice
versionPermit:7
second:0]) { 
//下面这段话如果在IOS5上运行的话会显示有点问题,所以这个地方注释
        NSDictionary *attributes=[NSDictionary
dictionaryWithObjectsAndKeys:[UIColor
blackColor],UITextAttributeTextColor,[UIFont
boldSystemFontOfSize:20],UITextAttributeFont,
nil];
        [viewController.navigationController.navigationBar
setTitleTextAttributes:attributes];
    }
    
    [btn release];
    [custom release];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐