ios – 没有调用previewActionItems(强制触摸动作)
发布时间:2020-12-14 17:17:46 所属栏目:百科 来源:网络整理
导读:我使用下面的代码来添加强制触摸预览操作… Peek和pop视图效果很好,只有动作没有显示…请帮助我的代码由于某种原因没有被执行,看看: - (NSArrayidUIPreviewActionItem *)previewActionItems { if (_previewActions == nil) { UIPreviewAction *rateAction =
我使用下面的代码来添加强制触摸预览操作… Peek和pop视图效果很好,只有动作没有显示…请帮助我的代码由于某种原因没有被执行,看看:
- (NSArray<id<UIPreviewActionItem>> *)previewActionItems { if (_previewActions == nil) { UIPreviewAction *rateAction = [UIPreviewAction actionWithTitle:@"Rate" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action,UIViewController * _Nonnull previewViewController) { EmbededRateViewController *embededRVC = [[EmbededRateViewController alloc]initWithEmployerToRate:self.employersArray[0]]; embededRVC.view.bounds = CGRectMake(0,self.view.frame.size.width - 40,210); [embededRVC setPopinTransitionStyle:BKTPopinTransitionStyleSnap]; BKTBlurParameters *blurParameters = [[BKTBlurParameters alloc] init]; blurParameters.tintColor = [UIColor colorWithWhite:0 alpha:0.5]; blurParameters.radius = 0.3f; // 0.3 [embededRVC setBlurParameters:blurParameters]; [embededRVC setPopinTransitionDirection:BKTPopinTransitionDirectionTop]; [self.collectionView setScrollEnabled:NO]; [self presentPopinController:embededRVC animated:YES completion:^{ NSLog(@"Popin presented !"); }]; }]; UIPreviewAction *commentAction = [UIPreviewAction actionWithTitle:@"Comment" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action,UIViewController * _Nonnull previewViewController) { NewCommentViewController *ncvc = [[NewCommentViewController alloc]initWithEmployer:self.employersArray[0]]; [self presentViewController:ncvc animated:YES completion:nil]; }]; UIPreviewAction *reportAction = [UIPreviewAction actionWithTitle:@"Report" style:UIPreviewActionStyleDestructive handler:^(UIPreviewAction * _Nonnull action,UIViewController * _Nonnull previewViewController) { ReportEmployerViewController *reportEmpVC = [[ReportEmployerViewController alloc]initWithEmployer:self.employersArray[0]]; [self presentViewController:reportEmpVC animated:YES completion:nil]; }]; UIPreviewAction *cancelAction = [UIPreviewAction actionWithTitle:@"Cancel" style:UIPreviewActionStyleSelected handler:^(UIPreviewAction *action,UIViewController *previewViewController){ }]; _previewActions = @[commentAction,rateAction,reportAction,cancelAction]; } return _previewActions; } 解决方法
我面临同样的问题被困了很长时间.
我犯的错误是在Caller View Controller中添加了这个方法. 例如,如果您在强制触摸View Controller A(调用者)时呈现View Controller B(调用),则将此方法添加到View Controller B(调用). 并且太明显了,因为我们正在处理View控制器B中的按钮操作. 希望它能帮到你.祝一切顺利. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |