Support nudges on UICollectionReusableView
Dynamic Views
Please follow below steps if you intend to run nudges on screens having UICollectionReusableView , UITableViewHeaderFooterView
Prerequisite
Support nudges on UICollectionReusableView , UITableViewHeaderFooterView is available from iOS SmartechNudge SDK v8.7.2 onwards
Assign a tag to the reusable views
UITableViewHeaderView :
(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CustomHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"CustomHeaderFooterViewId"];
headerView.tag = section;
return headerView;
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier:"CustomHeaderFooterViewId") as? CustomHeaderView {
headerView.tag = section
}
return headerView
}
UITableViewFooterView :
(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
CustomHeaderView *footerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"CustomHeaderFooterViewId"];
footerView.tag = section;
return footerView;
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if let footerView = tableView.dequeueReusableHeaderFooterView(withIdentifier:"CustomHeaderFooterViewId") as? CustomHeaderView {
footerView.tag = section
}
return footerView
}
UICollectionReusableView :
(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
UICollectionReusableView *view = nil;
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
view = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:headerReuseIdentifier forIndexPath:indexPath];
}
else if ([kind isEqualToString:UICollectionElementKindSectionFooter]) {
view = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:footerReuseIdentifier forIndexPath:indexPath];
}
view.tag = indexPath.section;
return view;
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
switch kind {
case UICollectionView.elementKindSectionHeader:
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerReuseIdentifier, for: indexPath)
headerView.tag = indexPath.section
return headerView
case UICollectionView.elementKindSectionFooter:
let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: footerReuseIdentifier, for: indexPath)
footerView.tag = indexPath.section
return footerView
default:
}
}
Updated 4 months ago