gpt4 book ai didi

ios - 从库中选择照片时如何禁用 UITapGestureRecognizer?

转载 作者:行者123 更新时间:2023-11-29 13:00:04 29 4
gpt4 key购买 nike

我正在使用 UITapGestureRecognizer

这是我的代码:

Home.m:

- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAnim:)];
[self.view addGestureRecognizer:tapGesture];

UIButton *buttontest = [[UIButton alloc] init];
buttontest.backgroundColor = [UIColor whiteColor];
buttontest.frame = CGRectMake(0, 80, 40, 40);
[buttontest addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:buttontest];
[self.view bringSubviewToFront:buttontest];
}
- (void)test: (UIButton*)aButton {
// TakePhoto *mvc = [[TakePhoto alloc]initWithNibName:@"TakePhoto" bundle:Nil];
// [self.navigationController pushViewController:mvc animated:YES];
//
// [self.view removeFromSuperview];

if (self.companyController) {
self.companyController = nil;
}
self.companyController = [[TakePhoto alloc] initWithNibName:@"TakePhoto" bundle:nil];
UIView *viewSuper = [[IQAppDelegate shareInstance] currentVisibleController].view;
UIViewController *profile = self.companyController;

profile.view.frame = viewSuper.frame;
[viewSuper addSubview:profile.view];
profile.view.frame = CGRectMake(viewSuper.frame.origin.x, viewSuper.frame.size.height, profile.view.frame.size.width, profile.view.frame.size.height);
[UIView beginAnimations:nil context: nil];
[UIView setAnimationDuration:0.35];

profile.view.frame = CGRectMake(viewSuper.frame.origin.x, viewSuper.frame.origin.x, profile.view.frame.size.width, profile.view.frame.size.height);

[UIView commitAnimations];
}

}
- (void) tapAnim: (UITapGestureRecognizer*)gestureRecognizer {
// Show something
}

拍照.m

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsEditing = NO;
[(UIViewController *)self.delegate presentModalViewController:picker animated:YES];

我添加了一个 view:Takephoto front of Home(我没有使用“push”),像这样:

--->首页

--->拍照(如弹出式显示):它有 2 个按钮“从库中选择照片”和“关闭”

当我使用“从图库中选择照片”功能时,我无法选择照片并且 UITapGestureRecognizer 始终显示。

如何在从图库中选择照片时禁用 UITapGestureRecognizer

P/S:对不起我的英语。

最佳答案

手势识别器具有 enabled 属性。将其设置为 NO 以禁用手势识别器。为了使这更容易,您应该使用实例变量保留对点击手势识别器的引用。

关于ios - 从库中选择照片时如何禁用 UITapGestureRecognizer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19993357/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com