ios - 如何同时禁用屏幕上的多个用户交互

标签 ios user-interface uiimageview uibutton

在我的应用程序中,不包含任何 UIElements,例如 facebook 按钮、twitter 按钮、注销按钮、带有手势的 imageview

`

facebookBtn = [UIButton buttonWithType:UIButtonTypeCustom];
 [facebookBtn setImage:@"facebook.png"];
 [facebookBtn addTarget:self action:@selector(switchToFacebookShare) forControlEvents:UIControlEventTouchUpInside];
 [facebookBtn setFrame:CGRectMake(0, 50, 24, 24)];
[self.view addsubview:facebookBtn];`

 `twitterBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  [twitterBtn setImage:@"facebook.png"];
  [twitterBtn addTarget:self action:@selector(switchToTwitterShare) forControlEvents:UIControlEventTouchUpInside];
  [twitterBtn setFrame:CGRectMake(0, 100, 24, 24)];
  [self.view addsubview:twitterBtn];`


`imageTapGesture =  [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sectionTapping:)];
 [imageTapGesture setNumberOfTapsRequired:1];`

`sectionPortraitImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
 [sectionPortraitImageView setUserInteractionEnabled:YES];
 [sectionPortraitImageView addGestureRecognizer:imageTapGesture];
 [contentView addSubview:sectionLandscapeImageView];`

像这样我添加了所有元素 当用户一次单击所有按钮时,所有三个功能都将起作用。 这里只需要做一项操作。

如何解决这个问题?

最佳答案

一次处理多个触摸问题并设置单独的属性

[sectionLandscapeImageView setExclusiveTouch:YES]; //处理所有 subview 的多次触摸用户交互

 -(void)multipleTouchHandling
{
    self.view.multipleTouchEnabled=NO;
    self.view.exclusiveTouch=YES;
    for(UIView* view1 in self.view.subviews)
    {
        if([view1 isKindOfClass:[UIButton class]])
        {
            UIButton* btnVw = (UIButton*)view1;
            [btnVw setExclusiveTouch:YES];
        }
    }
}

关于ios - 如何同时禁用屏幕上的多个用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27653214/

相关文章:

ios - Swift:UITableView 不使用 reloadData 进行更新

java - 阻止用户单击当前帧以外的其他位置的最佳方法?

android - 动画之后,使 ImageView 不可见

ios - 如何降低捏缩放 UIGestureRecognizer 的速度

ios - Use of unresolved identifier 'scope' 为什么这个错误会出现在下面的代码中

ios - 无法安装 Codename 一个 iOS 调试应用程序

java - 如何制作类似于Blackberry App World 的黑莓屏幕幻灯片动画?

c++ - 使用 PBM_SETPOS 设置位置时 ProgressBar 滞后

objective-c - 在具有裁剪过渡的图像之间滚动

iphone - 用两个 UIImageView 保存一个图像,其中有两个图像 - ios