Я использую код ниже, чтобы добавить принудительные действия предварительного просмотра ... Peek and pop view отлично работает, только действия не отображаются ... Пожалуйста, помогите моему коду не запускаться почему-то, посмотрите:previewActionItems не получает вызов (Force touch action)
- (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, 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;
}
Спасибо, что он сделал работу – miljan
Рад помочь приятелю :-) –