点击手势在模拟器中运行良好,但不能在iPad上运行

时间:2014-05-27 14:39:26

标签: ios objective-c ipad

这是我的代码:

// in viewdidload

UITapGestureRecognizer* gestureRecognizer_businessType = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerViewTapGestureRecognized:)];
gestureRecognizer_businessType.cancelsTouchesInView = NO;

[busType_pickerView  addGestureRecognizer:gestureRecognizer_businessType];


// in pickerViewTapGestureRecognized method

CGPoint point_businessType = [gestureRecognizer locationInView:busType_pickerView];
if (CGRectContainsPoint(locationRect, point_businessType))
{
    //code execution

}
else
{

}


///pickerview code


busType_pickerViewContainer.frame=CGRectMake(0, 0, 320, 216);
busType_pickerView.frame=CGRectMake(0, 0, 320, 216);
busType_pickerView.hidden = NO;
busType_pickerView.showsSelectionIndicator = YES;

[busType_pickerViewContainer addSubview:busType_pickerView];
[busType_viewController.view addSubview:busType_pickerViewContainer];

busType_popOverForPicker = [[UIPopoverController alloc]initWithContentViewController:busType_viewController];
busType_popOverForPicker.delegate = self;
busType_pickerView.userInteractionEnabled=YES;
[busType_popOverForPicker setPopoverContentSize:CGSizeMake(320, 216) animated:NO];
[busType_popOverForPicker presentPopoverFromRect:businessTypeBtn.frame inView:self.businessDetailsView  permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown| UIPopoverArrowDirectionLeft|UIPopoverArrowDirectionRight) animated:YES];

1 个答案:

答案 0 :(得分:0)

如果您将轻击手势识别器附加到UIPickerView,则选择器视图和手势识别器可能正在争夺点击。模拟器只是iOS的模拟,并且针对不同于iOS的框架运行。仅仅因为它在模拟器上工作并不意味着它可以在实际设备上工作。我已经碰到了好几次。