Skip to content
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

根据需求改变:已有占位图的时候再次reloadData会重新请求占位图而不是直接返回(用于从一个占位图直接切换到其他种类占位图的情况) #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion CYLTableViewPlaceHolder/UITableView+CYLTableViewPlaceHolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,23 @@ - (void)cyl_checkEmpty {
self.scrollWasEnabled = self.scrollEnabled;
BOOL scrollEnabled = NO;
if ([self respondsToSelector:@selector(enableScrollWhenPlaceHolderViewShowing)]) {
scrollEnabled = [self performSelector:@selector(enableScrollWhenPlaceHolderViewShowing)];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wint-conversion"
scrollEnabled = [self performSelector:@selector(enableScrollWhenPlaceHolderViewShowing)];
#pragma clang diagnostic pop

if (!scrollEnabled) {
NSString *reason = @"There is no need to return NO for `-enableScrollWhenPlaceHolderViewShowing`, it will be NO by default";
@throw [NSException exceptionWithName:NSGenericException
reason:reason
userInfo:nil];
}
} else if ([self.delegate respondsToSelector:@selector(enableScrollWhenPlaceHolderViewShowing)]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wint-conversion"
scrollEnabled = [self.delegate performSelector:@selector(enableScrollWhenPlaceHolderViewShowing)];
#pragma clang diagnostic pop

if (!scrollEnabled) {
NSString *reason = @"There is no need to return NO for `-enableScrollWhenPlaceHolderViewShowing`, it will be NO by default";
@throw [NSException exceptionWithName:NSGenericException
Expand Down Expand Up @@ -101,8 +109,15 @@ - (void)cyl_checkEmpty {
} else if (isEmpty) {
// Make sure it is still above all siblings.
[self.placeHolderView removeFromSuperview];
if ([self respondsToSelector:@selector(makePlaceHolderView)]) {
self.placeHolderView = [self performSelector:@selector(makePlaceHolderView)];
} else if ( [self.delegate respondsToSelector:@selector(makePlaceHolderView)]) {
self.placeHolderView = [self.delegate performSelector:@selector(makePlaceHolderView)];
}
self.placeHolderView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.placeHolderView];
}
}

@end