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

如何去除系统自带的UIImagePickerController 右侧的取消按钮

2013-12-06 11:09 344 查看
转载自:http://www.cocoachina.com/bbs/simple/?t2719.html

注意需要将 UIImagePickerController 这个类实例的delegate设为self

实现UINavigationControllerDelegate的接口如下
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIView *custom = [[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)];
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:custom];
[viewController.navigationItem setRightBarButtonItem:btn animated:NO];
[btn release];
[custom release];
}

刚才马远是这样做的,但貌似点击进去后再回来就又有了,先记下来吧,实际中还是用上边的那个方法好一点感觉:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    for (UINavigationItem *item
in navigationController.navigationBar.subviews) {
        if ([item
isKindOfClass:[UIButton
class]]&&([item.title
isEqualToString:@"取消"]||[item.title
isEqualToString:@"Cancel"]))
        {
            UIButton *button = (UIButton *)item;
            [button setHidden:YES];
        }
        
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: