-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UITableView 里面,怎么加到动态的cell上去? #5
Comments
调用observePath: badgeView: block: 这边的badgeView可以设置成cell的contentView, 然后调整badgeView的offset使其在右边中间显示(默认在右上角) 也可以在cell的相应位置add一个透明的UIImageView, 然后把badgeView设置成这个UIImageView 这边需要注意cell的复用的情况,如果cell复用了,那它对应的小红点keyPath也需要调整了,否则小红点的显示就乱了 cell的复用的情况下可以在endDisplayCell的回调中unObservePath, 然后在willDisPlayCell的时候重新addObservePath 或者如上面说的将小红点显示在UIImageView上,然后每次cellForItemAtIndexPath重新configCell/Data的时候直接把UIImageView删除后重新关联对应的path后new一个 |
cell上好像不能添加 |
按照二楼的步骤加呢? |
二楼好像也不行的,cell不够充满整个屏幕的没效果 |
调整下badgeOffset? 或者你贴个testbed出来我看一下 |
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *badgePath = [self badgePathAtIndexPath:indexPath];
if (badgePath) {
// cell.contentView.badgeOffset = CGPointMake(-5, 5);
[self.badgeController observePath:badgePath badgeView:cell.contentView block:nil];
}
}
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *badgePath = [self badgePathAtIndexPath:indexPath];
if (badgePath) {
[self.badgeController unobservePath:badgeKeyPath];
[cell.contentView hideBadge];
}
} 我们自己的工程里面是这么设置的,你试下呢 |
出个 cell 的demo,cell 的应用场景还是蛮多的 |
您好,请问动态的cell怎么加?点击之后消失。就像微信一样。
The text was updated successfully, but these errors were encountered: