Skip to content

Commit f91df62

Browse files
committed
修复一些小问题
1 parent d3e8249 commit f91df62

File tree

9 files changed

+36
-57
lines changed

9 files changed

+36
-57
lines changed

Example/FMLayoutKit/FMCollectionViewCell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
NS_ASSUME_NONNULL_BEGIN
1212

1313
@interface FMCollectionViewCell : UICollectionViewCell
14+
@property (weak, nonatomic) IBOutlet UILabel *label;
1415

1516
@end
1617

Example/FMLayoutKit/FMCollectionViewCell.xib

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
</constraints>
3434
<viewLayoutGuide key="safeArea" id="SEy-5g-ep8"/>
3535
<size key="customSize" width="138" height="147"/>
36+
<connections>
37+
<outlet property="label" destination="ZJk-95-5MF" id="9tF-3q-tC8"/>
38+
</connections>
3639
<point key="canvasLocation" x="-88" y="67"/>
3740
</collectionViewCell>
3841
</objects>

Example/FMLayoutKit/FMCombineViewController.m

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ @implementation FMCombineViewController
102102

103103
- (void)viewDidLoad {
104104
[super viewDidLoad];
105+
105106
FMLayoutView *view = [[FMLayoutView alloc] init];
106107
// view.layout.minContentSize = 1000;
107108
view.backgroundColor = [UIColor whiteColor];
@@ -115,11 +116,13 @@ - (void)viewDidLoad {
115116
// [self addCrossFixedSections];
116117
// [self addScaleSection];
117118
self.collectionView.enableLongPressDrag = YES;
118-
[self.collectionView setConfigureSourceView:^UIView * _Nonnull(UICollectionViewCell * _Nonnull sourceCell) {
119-
UIView *source = [[UIView alloc] initWithFrame:sourceCell.frame];
120-
source.backgroundColor = [UIColor purpleColor];
121-
return source;
122-
}];
119+
// [self.collectionView setConfigureSourceView:^UIView * _Nonnull(UICollectionViewCell * _Nonnull sourceCell) {
120+
// UIView *source = [[UIView alloc] initWithFrame:sourceCell.frame];
121+
// source.backgroundColor = [UIColor purpleColor];
122+
// return source;
123+
// }];
124+
125+
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"刷新" style:UIBarButtonItemStylePlain target:self.collectionView action:@selector(reloadData)];
123126
}
124127

125128
- (void)addSections{
@@ -143,17 +146,18 @@ - (void)addSections{
143146
section.footer.topMargin = 10;
144147

145148
section.itemSize = CGSizeMake(200, 100);
146-
section.itemDatas = [@[@"1", @"2", @"3"] mutableCopy];
149+
section.itemDatas = [@[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9"] mutableCopy];
147150
section.cellElement = [FMLayoutElement elementWithViewClass:[FMCollectionViewCell class] isNib:YES];
148151
[section setConfigureCellData:^(FMLayoutBaseSection * _Nonnull section, UICollectionViewCell * _Nonnull cell, NSInteger item) {
149-
152+
[(FMCollectionViewCell *)cell label].text = section.itemDatas[item];
150153
}];
151154

152155
[section setClickCellBlock:^(FMLayoutBaseSection * _Nonnull section, NSInteger item) {
153156
FMAddViewController *add = [[FMAddViewController alloc] init];
154157
[weakSelf.navigationController pushViewController:add animated:YES];
155158
}];
156159

160+
section.canLongPressExchange = YES;
157161
[sections addObject:section];
158162
}
159163
{
@@ -162,10 +166,10 @@ - (void)addSections{
162166
FMLayoutFixedSection *section = [FMLayoutFixedSection sectionWithSectionInset:UIEdgeInsetsMake(0, 0, 0, 0) itemSpace:10 lineSpace:10 column:2];
163167

164168
section.itemSize = CGSizeMake(150, 100);
165-
section.itemDatas = [@[@"1", @"2", @"3", @"2", @"3", @"2", @"3", @"2", @"3", @"2", @"3"] mutableCopy];
169+
section.itemDatas = [@[@"0-1", @"0-2", @"0-3", @"0-4", @"0-5", @"0-6", @"0-7", @"0-8", @"0-9", @"0-10", @"0-11"] mutableCopy];
166170
section.cellElement = [FMLayoutElement elementWithViewClass:[FMCollectionCustomCell class]];
167171
[section setConfigureCellData:^(FMLayoutBaseSection * _Nonnull section, UICollectionViewCell * _Nonnull cell, NSInteger item) {
168-
[(FMCollectionCustomCell *)cell label].text = [NSString stringWithFormat:@"%ld", (long)item];
172+
[(FMCollectionCustomCell *)cell label].text = section.itemDatas[item];
169173
}];
170174
[section setClickCellBlock:^(FMLayoutBaseSection * _Nonnull section, NSInteger item) {
171175

@@ -176,7 +180,7 @@ - (void)addSections{
176180
{
177181
FMLayoutAbsoluteSection *section = [FMLayoutAbsoluteSection sectionWithSectionInset:UIEdgeInsetsMake(0, 0, 0, 0) itemSpace:0 lineSpace:0 column:0];
178182

179-
section.itemDatas = [@[@"1", @"2", @"3"] mutableCopy];
183+
section.itemDatas = [@[@"1-1", @"1-2", @"1-3"] mutableCopy];
180184
section.cellElements = @[[FMLayoutElement elementWithViewClass:[FMCollectionCustomCell class]]];
181185
[section setDeqCellReturnReuseId:^NSString * _Nonnull(FMLayoutDynamicSection * _Nonnull section, NSInteger index) {
182186
return [section.cellElements firstObject].reuseIdentifier;
@@ -195,7 +199,7 @@ - (void)addSections{
195199
}
196200
}];
197201
[section setConfigureCellData:^(FMLayoutBaseSection * _Nonnull section, UICollectionViewCell * _Nonnull cell, NSInteger item) {
198-
[(FMCollectionCustomCell *)cell label].text = [NSString stringWithFormat:@"%ld", (long)item];
202+
[(FMCollectionCustomCell *)cell label].text = section.itemDatas[item];
199203
}];
200204
[section setClickCellBlock:^(FMLayoutBaseSection * _Nonnull section, NSInteger item) {
201205

FMLayoutKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'FMLayoutKit'
11-
s.version = '1.0.9'
11+
s.version = '1.1.1'
1212
s.summary = 'A short description of FMLayoutKit.'
1313

1414
# This description is used to generate tags and improve search results.

FMLayoutKit/Classes/FMLayoutView.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ - (void)initSourceView{
264264
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
265265

266266
sourceView = [[UIView alloc] initWithFrame:sourceCell.frame];
267-
sourceView.backgroundColor = [UIColor purpleColor];
268267
sourceView.layer.shadowColor = [UIColor darkGrayColor].CGColor;
269268
sourceView.layer.shadowOffset = CGSizeMake(0, 0);
270269
sourceView.layer.shadowOpacity = 0.7;

FMLayoutKit/Classes/Sections/FMLayoutBaseSection.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ - (CGFloat)crossSingleSectionSize{
379379
}
380380

381381
- (void)exchangeObjectAtIndex:(NSInteger)index toIndex:(NSInteger)toIndex{
382-
[self.itemDatas exchangeObjectAtIndex:index withObjectAtIndex:toIndex];
382+
id obj = self.itemDatas[index];
383+
[self.itemDatas removeObjectAtIndex:index];
384+
[self.itemDatas insertObject:obj atIndex:toIndex];
383385
}
384386

385387
- (UICollectionViewCell *)dequeueReusableCellForIndexPath:(NSIndexPath *)indexPath{

FMLayoutKit/Classes/Sections/FMLayoutCombineSection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#import "FMLayoutBaseSection.h"
99

1010
NS_ASSUME_NONNULL_BEGIN
11-
///可以将不同Cell, 不同的布局方式, 放到同一个分组去合并,只合并cell, 如果子分组有头部和底部讲被忽略,合并分组的头部与底部不影响配置, cell的点击事件已经在init方法中配置block分发到子分组上
11+
///可以将不同Cell, 不同的布局方式, 放到同一个分组去合并,只合并cell, 如果子分组有头部和底部讲被忽略,合并分组的头部与底部不影响配置, cell的点击事件已经在init方法中配置block分发到子分组上 合并分组不支持拖拽排序 想要支持 可以继承自该类重写canLongPressExchange的get方法 并实现- (void)exchangeObjectAtIndex:(NSInteger)index toIndex:(NSInteger)toIndex;
1212
@interface FMLayoutCombineSection : FMLayoutBaseSection
1313

1414
+ (instancetype)combineSections:(NSArray<FMLayoutBaseSection *> *)sections;

FMLayoutKit/Classes/Sections/FMLayoutCombineSection.m

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ @interface FMLayoutCombineSection ()
3030

3131
@implementation FMLayoutCombineSection
3232

33+
- (BOOL)canLongPressExchange{
34+
return NO;
35+
}
36+
3337
- (NSArray<FMLayoutBaseSection *> *)subSections{
3438
return [self.sections valueForKey:@"section"];
3539
}
@@ -72,7 +76,7 @@ - (instancetype)init
7276
if (com.section.clickCellBlock) {
7377
com.section.clickCellBlock(com.section, item - com.start);
7478
}
75-
break;
79+
return;
7680
}
7781
}
7882
}];
@@ -82,7 +86,7 @@ - (instancetype)init
8286
if (com.section.configureCellData) {
8387
com.section.configureCellData(com.section, cell,item - com.start);
8488
}
85-
break;
89+
return;
8690
}
8791
}
8892
}];
@@ -194,39 +198,4 @@ - (CGFloat)crossSingleSectionSize{
194198
return maxSize;
195199
}
196200

197-
- (void)exchangeObjectAtIndex:(NSInteger)index toIndex:(NSInteger)toIndex{
198-
NSMutableArray *get;
199-
NSMutableArray *inset;
200-
NSInteger getIndex = 0;
201-
NSInteger insetIndex = 0;
202-
NSInteger start = 0;
203-
NSArray *sections = self.subSections;
204-
for (FMLayoutBaseSection *section in sections) {
205-
if (index < start + section.itemCount) {
206-
if (!get) {
207-
get = section.itemDatas;
208-
getIndex = index - start;
209-
}
210-
}
211-
if (toIndex < start + section.itemCount) {
212-
if (!inset) {
213-
inset = section.itemDatas;
214-
insetIndex = toIndex - start;
215-
}
216-
}
217-
if (get && inset) {
218-
break;
219-
}
220-
start += section.itemCount;
221-
}
222-
id getObj = [get objectAtIndex:getIndex];
223-
id insetObj = [inset objectAtIndex:insetIndex];
224-
if (get == inset) {
225-
[get exchangeObjectAtIndex:getIndex withObjectAtIndex:insetIndex];
226-
} else {
227-
[get replaceObjectAtIndex:getIndex withObject:insetObj];
228-
[inset replaceObjectAtIndex:insetIndex withObject:getObj];
229-
}
230-
}
231-
232201
@end

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,19 @@ multi.dataSource = self;
201201
- (NSInteger)numberOfScreenInTesla:(nonnull FMTeslaLayoutView *)tesla {
202202
return 4;
203203
}
204-
/// 对应页面的view需要展示的Sections集合
205-
- (nonnull NSMutableArray<FMLayoutBaseSection *> *)tesla:(nonnull FMTeslaLayoutView *)tesla sectionsInScreenIndex:(NSInteger)screenIndex {
206-
return [self.sections mutableCopy];
207-
}
204+
208205
/// 头部共享的集合
209206
- (NSArray<FMLayoutBaseSection *> *)shareSectionsInTesla:(FMTeslaLayoutView *)tesla{
210207
return self.shareSections;
211208
}
212209

213210
```
214211
#### 版本更新
215-
2020-07-21(1.0.9)
212+
2020-07-21(1.1.1)
213+
合并取消支持拖拽, 会出现多重问题, 拖拽切换数据的问题修复
214+
215+
2020-07-21(1.1.0)
216+
清楚长按拖拽View的背景色
216217
长按拖拽可控制分组中某些item不支持拖拽, 修复合并分组的奔溃问题
217218
218219
2020-07-20(1.0.8)

0 commit comments

Comments
 (0)