3D Touch Peek-and-Pop API causes `touchesEnded:withEvent:` to be called multiple times on long press
| Originator: | RichWChan | ||
| Number: | rdar://22910171 | Date Originated: | 29-Sep-2015 |
| Status: | Open | Resolved: | |
| Product: | iOS | Product Version: | iOS 9.0, iOS 9.0.1 |
| Classification: | UI/Usability | Reproducible: | Always |
Summary:
After invoking `registerForPreviewingWithDelegate:sourceView:` on a view, the view's `touchesEnded:withEvent:` will get invoked twice instead of once after a long-press.
Steps to Reproduce:
1. Call `registerForPreviewingWithDelegate:sourceView:` on source view X
2. On the device, long press on view X
3. When releasing view X, its `touchesEnded:withEvent:` method will be called twice
Expected Results:
`touchesEnded` should only be called once.
Actual Results:
`touchesEnded` called twice in a row.
Logs as copied from the test project -- note that `touchesBegan` is only called once as expected, but `touchesEnded` is invoked twice.
2015-09-29 21:17:41.455 TouchTester[43302:4211441] touchesBegan
2015-09-29 21:17:42.307 TouchTester[43302:4211441] touchesEnded
2015-09-29 21:17:42.307 TouchTester[43302:4211441] touchesEnded
Version:
iOS 9.0, iOS 9.0.1
Notes:
Configuration:
iPhone 6s
Attachments:
[Sample code copied below:]
```
#import "ViewController.h"
@interface TestView : UIView
@end
@interface ViewController () <UIViewControllerPreviewingDelegate>
@end
@implementation ViewController
{
TestView *_view;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_view = [[TestView alloc] initWithFrame:CGRectInset(self.view.bounds, 40, 40)];
_view.backgroundColor = [UIColor grayColor];
_view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:_view];
[self registerForPreviewingWithDelegate:self sourceView:_view];
}
- (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
{
return nil;
}
- (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit
{
}
@end
@implementation TestView
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
NSLog(@"touchesBegan");
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
NSLog(@"touchesEnded");
}
@end
```
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!