Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
dz_TZImagePickerController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuijing
dz_TZImagePickerController
Commits
d88890c8
Commit
d88890c8
authored
Aug 28, 2016
by
tanzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复长按排序的一些bug
parent
7a40ab9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
TZImagePickerController/LxGridViewFlowLayout.h
TZImagePickerController/LxGridViewFlowLayout.h
+0
-1
TZImagePickerController/LxGridViewFlowLayout.m
TZImagePickerController/LxGridViewFlowLayout.m
+0
-3
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+22
-16
No files found.
TZImagePickerController/LxGridViewFlowLayout.h
View file @
d88890c8
...
...
@@ -15,7 +15,6 @@
@interface
LxGridViewFlowLayout
:
UICollectionViewFlowLayout
@property
(
nonatomic
,
assign
)
BOOL
panGestureRecognizerEnable
;
@property
(
nonatomic
,
assign
)
NSInteger
itemCount
;
@end
...
...
TZImagePickerController/LxGridViewFlowLayout.m
View file @
d88890c8
...
...
@@ -314,9 +314,6 @@ CG_INLINE CGPoint CGPointOffset(CGPoint point, CGFloat dx, CGFloat dy)
if
((
destinationIndexPath
==
nil
)
||
[
destinationIndexPath
isEqual
:
sourceIndexPath
])
{
return
;
}
if
(
sourceIndexPath
.
item
>=
self
.
itemCount
||
destinationIndexPath
.
item
>=
self
.
itemCount
)
{
return
;
}
if
([
self
.
dataSource
respondsToSelector
:
@selector
(
collectionView
:
itemAtIndexPath
:
canMoveToIndexPath
:
)]
&&
[
self
.
dataSource
collectionView
:
self
.
collectionView
itemAtIndexPath
:
sourceIndexPath
canMoveToIndexPath
:
destinationIndexPath
]
==
NO
)
{
return
;
...
...
TZImagePickerController/ViewController.m
View file @
d88890c8
...
...
@@ -23,7 +23,6 @@
CGFloat
_itemWH
;
CGFloat
_margin
;
LxGridViewFlowLayout
*
_layout
;
}
@property
(
nonatomic
,
strong
)
UIImagePickerController
*
imagePickerVc
;
@property
(
nonatomic
,
strong
)
UICollectionView
*
collectionView
;
...
...
@@ -77,13 +76,13 @@
}
-
(
void
)
configCollectionView
{
_
layout
=
[[
LxGridViewFlowLayout
alloc
]
init
];
LxGridViewFlowLayout
*
layout
=
[[
LxGridViewFlowLayout
alloc
]
init
];
_margin
=
4
;
_itemWH
=
(
self
.
view
.
tz_width
-
2
*
_margin
-
4
)
/
3
-
_margin
;
_
layout
.
itemSize
=
CGSizeMake
(
_itemWH
,
_itemWH
);
_
layout
.
minimumInteritemSpacing
=
_margin
;
_
layout
.
minimumLineSpacing
=
_margin
;
_collectionView
=
[[
UICollectionView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
344
,
self
.
view
.
tz_width
,
self
.
view
.
tz_height
-
344
)
collectionViewLayout
:
_
layout
];
layout
.
itemSize
=
CGSizeMake
(
_itemWH
,
_itemWH
);
layout
.
minimumInteritemSpacing
=
_margin
;
layout
.
minimumLineSpacing
=
_margin
;
_collectionView
=
[[
UICollectionView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
344
,
self
.
view
.
tz_width
,
self
.
view
.
tz_height
-
344
)
collectionViewLayout
:
layout
];
CGFloat
rgb
=
244
/
255
.
0
;
_collectionView
.
alwaysBounceVertical
=
YES
;
_collectionView
.
backgroundColor
=
[
UIColor
colorWithRed
:
rgb
green
:
rgb
blue
:
rgb
alpha
:
1
.
0
];
...
...
@@ -155,7 +154,6 @@
_selectedPhotos
=
[
NSMutableArray
arrayWithArray
:
photos
];
_selectedAssets
=
[
NSMutableArray
arrayWithArray
:
assets
];
_isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
_layout
.
itemCount
=
_selectedPhotos
.
count
;
[
_collectionView
reloadData
];
_collectionView
.
contentSize
=
CGSizeMake
(
0
,
((
_selectedPhotos
.
count
+
2
)
/
3
)
*
(
_margin
+
_itemWH
));
}];
...
...
@@ -164,14 +162,25 @@
}
}
-
(
BOOL
)
collectionView
:(
UICollectionView
*
)
collectionView
canMoveItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
return
indexPath
.
item
<
_selectedPhotos
.
count
;
}
-
(
BOOL
)
collectionView
:(
UICollectionView
*
)
collectionView
itemAtIndexPath
:(
NSIndexPath
*
)
sourceIndexPath
canMoveToIndexPath
:(
NSIndexPath
*
)
destinationIndexPath
{
return
(
sourceIndexPath
.
item
<
_selectedPhotos
.
count
&&
destinationIndexPath
.
item
<
_selectedPhotos
.
count
);
}
-
(
void
)
collectionView
:(
UICollectionView
*
)
collectionView
itemAtIndexPath
:(
NSIndexPath
*
)
sourceIndexPath
didMoveToIndexPath
:(
NSIndexPath
*
)
destinationIndexPath
{
if
(
sourceIndexPath
.
item
>=
_selectedPhotos
.
count
||
destinationIndexPath
.
item
>=
_selectedPhotos
.
count
)
return
;
UIImage
*
image
=
_selectedPhotos
[
sourceIndexPath
.
item
];
if
(
image
)
{
[
_selectedPhotos
exchangeObjectAtIndex
:
sourceIndexPath
.
item
withObjectAtIndex
:
destinationIndexPath
.
item
];
[
_selectedAssets
exchangeObjectAtIndex
:
sourceIndexPath
.
item
withObjectAtIndex
:
destinationIndexPath
.
item
];
[
_collectionView
reloadData
];
}
[
_selectedPhotos
removeObjectAtIndex
:
sourceIndexPath
.
item
];
[
_selectedPhotos
insertObject
:
image
atIndex
:
destinationIndexPath
.
item
];
id
asset
=
_selectedAssets
[
sourceIndexPath
.
item
];
[
_selectedAssets
removeObjectAtIndex
:
sourceIndexPath
.
item
];
[
_selectedAssets
insertObject
:
asset
atIndex
:
destinationIndexPath
.
item
];
[
_collectionView
reloadData
];
}
#pragma mark - TZImagePickerController
...
...
@@ -333,7 +342,6 @@
_selectedPhotos
=
[
NSMutableArray
arrayWithArray
:
photos
];
_selectedAssets
=
[
NSMutableArray
arrayWithArray
:
assets
];
_isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
_layout
.
itemCount
=
_selectedPhotos
.
count
;
[
_collectionView
reloadData
];
// _collectionView.contentSize = CGSizeMake(0, ((_selectedPhotos.count + 2) / 3 ) * (_margin + _itemWH));
}
...
...
@@ -345,7 +353,6 @@
-
(
void
)
imagePickerController
:(
TZImagePickerController
*
)
picker
didFinishPickingVideo
:(
UIImage
*
)
coverImage
sourceAssets
:(
id
)
asset
{
_selectedPhotos
=
[
NSMutableArray
arrayWithArray
:@[
coverImage
]];
_selectedAssets
=
[
NSMutableArray
arrayWithArray
:@[
asset
]];
_layout
.
itemCount
=
_selectedPhotos
.
count
;
// open this code to send video / 打开这段代码发送视频
// [[TZImageManager manager] getVideoOutputPathWithAsset:asset completion:^(NSString *outputPath) {
// NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath);
...
...
@@ -362,7 +369,6 @@
-
(
void
)
deleteBtnClik
:(
UIButton
*
)
sender
{
[
_selectedPhotos
removeObjectAtIndex
:
sender
.
tag
];
[
_selectedAssets
removeObjectAtIndex
:
sender
.
tag
];
_layout
.
itemCount
=
_selectedPhotos
.
count
;
[
_collectionView
performBatchUpdates
:
^
{
NSIndexPath
*
indexPath
=
[
NSIndexPath
indexPathForItem
:
sender
.
tag
inSection
:
0
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment