应用的皮肤不能删除
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#import "KBMyVM.h"
|
||||
#import "KBMyTheme.h"
|
||||
#import "KBHUD.h"
|
||||
#import "KBSkinManager.h"
|
||||
|
||||
static NSString * const kMySkinCellId = @"kMySkinCellId";
|
||||
|
||||
@@ -254,6 +255,25 @@ static NSString * const kMySkinCellId = @"kMySkinCellId";
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.isEditingMode) {
|
||||
KBMyTheme *theme = self.data[indexPath.item];
|
||||
NSString *currentSkinId = [KBSkinManager shared].current.skinId;
|
||||
// themeId 可能是 NSString 或 NSNumber,统一转字符串比较
|
||||
NSString *themeIdStr = nil;
|
||||
if ([theme.themeId isKindOfClass:[NSString class]]) {
|
||||
themeIdStr = theme.themeId;
|
||||
} else if ([theme.themeId respondsToSelector:@selector(stringValue)]) {
|
||||
themeIdStr = [(id)theme.themeId stringValue];
|
||||
}
|
||||
if (currentSkinId.length > 0 && themeIdStr.length > 0 && [themeIdStr isEqualToString:currentSkinId]) {
|
||||
[KBHUD showInfo:KBLocalized(@"The skin in use cannot be deleted")];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (!self.isEditingMode) {
|
||||
// 非编辑态:可在此进入详情,当前示例不处理
|
||||
|
||||
Reference in New Issue
Block a user