如何去除系统自带的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];
}
}
}
注意需要将 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];
}
}
}
相关文章推荐
- UIImagePickerController控件自带按钮显示中文的办法
- ios UIImagePickerController取消按钮颜色
- 关于将系统自带的UIImagePickerController 作为uitabbarcontroller时 present时出现问题的解决
- 解决当把系统自带的UIImagePickerController 作为一个uiviewcontroller时有20像素间隙的问题
- UIImagePickerController 如何显示中文界面
- 系统简单的UIImagePickerController
- Iphone利用UIImagePickerController调用系统照相机
- 调用系统功能-UIImagePickerController-相册/相机/相簿
- iOS UISearchController中 如何改变UISearchBar中取消按钮的颜色和字
- IOS 横屏中添加UIImagePickerController获取系统图片
- 调用系统UIImagePickerController录像并保存到指定的文件夹,解决保存后播放视频角度偏移90度问题
- iOS 横屏中添加UIImagePickerController获取系统图片
- UIImagePickerController 调用系统相机 相册
- 用UIImagePickerController调用系统照相机
- 如何禁用系统分录的自带的增加、删除、插入按钮
- UIImagePickerController按钮的中文问题
- 点击按钮更换图片(图片按钮)(要加协议UIImagePickerControllerDelegate)
- iOS UIImagePickerController 的按钮显示中文
- 修改 UIImagePickerController 选择照片状态栏颜色及导航栏按钮标题字体颜色
- Iphone利用UIImagePickerController调用系统照相机