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
541a0a7f
Commit
541a0a7f
authored
Jun 03, 2017
by
yuzheng.tz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化性能:1. 初次进入时,提前渲染相册列表的tableView,避免初次进入相册页时的瞬间空白;2. 每次返回到相册页时,计算选中数量的任务放到后台,提升跳转流畅度
parent
c4fb9265
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
73 deletions
+79
-73
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+41
-49
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.h
...troller/TZImagePickerController/TZPhotoPickerController.h
+0
-2
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+37
-21
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+1
-1
No files found.
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
541a0a7f
...
@@ -281,12 +281,10 @@
...
@@ -281,12 +281,10 @@
}];
}];
}
}
if
(
!
_pushPhotoPickerVc
)
{
TZAlbumPickerController
*
albumPickerVc
=
(
TZAlbumPickerController
*
)
self
.
visibleViewController
;
TZAlbumPickerController
*
albumPickerVc
=
(
TZAlbumPickerController
*
)
self
.
visibleViewController
;
if
([
albumPickerVc
isKindOfClass
:[
TZAlbumPickerController
class
]])
{
if
([
albumPickerVc
isKindOfClass
:[
TZAlbumPickerController
class
]])
{
[
albumPickerVc
configTableView
];
[
albumPickerVc
configTableView
];
}
}
}
}
}
-
(
void
)
showAlertWithTitle
:(
NSString
*
)
title
{
-
(
void
)
showAlertWithTitle
:(
NSString
*
)
title
{
...
@@ -525,10 +523,10 @@
...
@@ -525,10 +523,10 @@
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
view
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
navigationItem
.
title
=
[
NSBundle
tz_localizedStringForKey
:
@"Photos"
];
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
self
.
navigationItem
.
rightBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
imagePickerVc
.
cancelBtnTitleStr
style
:
UIBarButtonItemStylePlain
target
:
imagePickerVc
action
:
@selector
(
cancelButtonClick
)];
self
.
navigationItem
.
rightBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
imagePickerVc
.
cancelBtnTitleStr
style
:
UIBarButtonItemStylePlain
target
:
imagePickerVc
action
:
@selector
(
cancelButtonClick
)];
[
self
configTableView
];
// 1.6.10 采用微信的方式,只在相册列表页定义backBarButtonItem为返回,其余的顺系统的做法
// 1.6.10 采用微信的方式,只在相册列表页定义backBarButtonItem为返回,其余的顺系统的做法
self
.
navigationItem
.
backBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:[
NSBundle
tz_localizedStringForKey
:
@"Back"
]
style
:
UIBarButtonItemStylePlain
target
:
nil
action
:
nil
];
self
.
navigationItem
.
backBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:[
NSBundle
tz_localizedStringForKey
:
@"Back"
]
style
:
UIBarButtonItemStylePlain
target
:
nil
action
:
nil
];
}
}
...
@@ -537,30 +535,26 @@
...
@@ -537,30 +535,26 @@
[
super
viewWillAppear
:
animated
];
[
super
viewWillAppear
:
animated
];
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
[
imagePickerVc
hideProgressHUD
];
[
imagePickerVc
hideProgressHUD
];
if
(
_albumArr
)
{
for
(
TZAlbumModel
*
albumModel
in
_albumArr
)
{
albumModel
.
selectedModels
=
imagePickerVc
.
selectedModels
;
}
[
_tableView
reloadData
];
}
else
{
[
self
configTableView
];
}
if
(
imagePickerVc
.
allowTakePicture
)
{
if
(
imagePickerVc
.
allowTakePicture
)
{
self
.
navigationItem
.
title
=
[
NSBundle
tz_localizedStringForKey
:
@"Photos"
];
self
.
navigationItem
.
title
=
[
NSBundle
tz_localizedStringForKey
:
@"Photos"
];
}
else
if
(
imagePickerVc
.
allowPickingVideo
)
{
}
else
if
(
imagePickerVc
.
allowPickingVideo
)
{
self
.
navigationItem
.
title
=
[
NSBundle
tz_localizedStringForKey
:
@"Videos"
];
self
.
navigationItem
.
title
=
[
NSBundle
tz_localizedStringForKey
:
@"Videos"
];
}
}
[
self
configTableView
];
}
}
-
(
void
)
configTableView
{
-
(
void
)
configTableView
{
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
[[
TZImageManager
manager
]
getAllAlbums
:
imagePickerVc
.
allowPickingVideo
allowPickingImage
:
imagePickerVc
.
allowPickingImage
completion
:^
(
NSArray
<
TZAlbumModel
*>
*
models
)
{
[[
TZImageManager
manager
]
getAllAlbums
:
imagePickerVc
.
allowPickingVideo
allowPickingImage
:
imagePickerVc
.
allowPickingImage
completion
:^
(
NSArray
<
TZAlbumModel
*>
*
models
)
{
_albumArr
=
[
NSMutableArray
arrayWithArray
:
models
];
_albumArr
=
[
NSMutableArray
arrayWithArray
:
models
];
for
(
TZAlbumModel
*
albumModel
in
_albumArr
)
{
for
(
TZAlbumModel
*
albumModel
in
_albumArr
)
{
albumModel
.
selectedModels
=
imagePickerVc
.
selectedModels
;
albumModel
.
selectedModels
=
imagePickerVc
.
selectedModels
;
}
}
if
(
!
_tableView
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
!
_tableView
)
{
CGFloat
top
=
0
;
CGFloat
top
=
0
;
CGFloat
tableViewHeight
=
0
;
CGFloat
tableViewHeight
=
0
;
if
(
self
.
navigationController
.
navigationBar
.
isTranslucent
)
{
if
(
self
.
navigationController
.
navigationBar
.
isTranslucent
)
{
...
@@ -583,7 +577,9 @@
...
@@ -583,7 +577,9 @@
}
else
{
}
else
{
[
_tableView
reloadData
];
[
_tableView
reloadData
];
}
}
});
}];
}];
});
}
}
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
...
@@ -610,10 +606,6 @@
...
@@ -610,10 +606,6 @@
photoPickerVc
.
columnNumber
=
self
.
columnNumber
;
photoPickerVc
.
columnNumber
=
self
.
columnNumber
;
TZAlbumModel
*
model
=
_albumArr
[
indexPath
.
row
];
TZAlbumModel
*
model
=
_albumArr
[
indexPath
.
row
];
photoPickerVc
.
model
=
model
;
photoPickerVc
.
model
=
model
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
photoPickerVc
setBackButtonClickHandle
:
^
(
TZAlbumModel
*
model
)
{
[
weakSelf
configTableView
];
}];
[
self
.
navigationController
pushViewController
:
photoPickerVc
animated
:
YES
];
[
self
.
navigationController
pushViewController
:
photoPickerVc
animated
:
YES
];
[
tableView
deselectRowAtIndexPath
:
indexPath
animated
:
NO
];
[
tableView
deselectRowAtIndexPath
:
indexPath
animated
:
NO
];
}
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.h
View file @
541a0a7f
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
@property
(
nonatomic
,
assign
)
NSInteger
columnNumber
;
@property
(
nonatomic
,
assign
)
NSInteger
columnNumber
;
@property
(
nonatomic
,
strong
)
TZAlbumModel
*
model
;
@property
(
nonatomic
,
strong
)
TZAlbumModel
*
model
;
@property
(
nonatomic
,
copy
)
void
(
^
backButtonClickHandle
)(
TZAlbumModel
*
model
);
@end
@end
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
541a0a7f
...
@@ -71,6 +71,15 @@ static CGSize AssetGridThumbnailSize;
...
@@ -71,6 +71,15 @@ static CGSize AssetGridThumbnailSize;
self
.
navigationItem
.
title
=
_model
.
name
;
self
.
navigationItem
.
title
=
_model
.
name
;
self
.
navigationItem
.
rightBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
tzImagePickerVc
.
cancelBtnTitleStr
style
:
UIBarButtonItemStylePlain
target
:
tzImagePickerVc
action
:
@selector
(
cancelButtonClick
)];
self
.
navigationItem
.
rightBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
tzImagePickerVc
.
cancelBtnTitleStr
style
:
UIBarButtonItemStylePlain
target
:
tzImagePickerVc
action
:
@selector
(
cancelButtonClick
)];
_showTakePhotoBtn
=
(([[
TZImageManager
manager
]
isCameraRollAlbum
:
_model
.
name
])
&&
tzImagePickerVc
.
allowTakePicture
);
_showTakePhotoBtn
=
(([[
TZImageManager
manager
]
isCameraRollAlbum
:
_model
.
name
])
&&
tzImagePickerVc
.
allowTakePicture
);
// [self resetCachedAssets];
}
-
(
void
)
fetchAssetModels
{
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
if
(
_isFirstAppear
)
{
[
tzImagePickerVc
showProgressHUD
];
}
dispatch_sync
(
dispatch_get_global_queue
(
0
,
0
),
^
{
if
(
!
tzImagePickerVc
.
sortAscendingByModificationDate
&&
_isFirstAppear
&&
iOS8Later
)
{
if
(
!
tzImagePickerVc
.
sortAscendingByModificationDate
&&
_isFirstAppear
&&
iOS8Later
)
{
[[
TZImageManager
manager
]
getCameraRollAlbum
:
tzImagePickerVc
.
allowPickingVideo
allowPickingImage
:
tzImagePickerVc
.
allowPickingImage
completion
:^
(
TZAlbumModel
*
model
)
{
[[
TZImageManager
manager
]
getCameraRollAlbum
:
tzImagePickerVc
.
allowPickingVideo
allowPickingImage
:
tzImagePickerVc
.
allowPickingImage
completion
:^
(
TZAlbumModel
*
model
)
{
_model
=
model
;
_model
=
model
;
...
@@ -88,22 +97,26 @@ static CGSize AssetGridThumbnailSize;
...
@@ -88,22 +97,26 @@ static CGSize AssetGridThumbnailSize;
[
self
initSubviews
];
[
self
initSubviews
];
}
}
}
}
// [self resetCachedAssets]
;
})
;
}
}
-
(
void
)
initSubviews
{
-
(
void
)
initSubviews
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
[
tzImagePickerVc
hideProgressHUD
];
[
self
checkSelectedModels
];
[
self
checkSelectedModels
];
[
self
configCollectionView
];
[
self
configCollectionView
];
[
self
configBottomToolBar
];
[
self
configBottomToolBar
];
[
self
scrollCollectionViewToBottom
];
});
}
}
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
{
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
{
[
super
viewWillDisappear
:
animated
];
[
super
viewWillDisappear
:
animated
];
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
tzImagePickerVc
.
isSelectOriginalPhoto
=
_isSelectOriginalPhoto
;
tzImagePickerVc
.
isSelectOriginalPhoto
=
_isSelectOriginalPhoto
;
if
(
self
.
backButtonClickHandle
)
{
self
.
backButtonClickHandle
(
_model
);
}
}
}
-
(
BOOL
)
prefersStatusBarHidden
{
-
(
BOOL
)
prefersStatusBarHidden
{
...
@@ -151,7 +164,6 @@ static CGSize AssetGridThumbnailSize;
...
@@ -151,7 +164,6 @@ static CGSize AssetGridThumbnailSize;
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
[
super
viewWillAppear
:
animated
];
[
self
scrollCollectionViewToBottom
];
// Determine the size of the thumbnails to request from the PHCachingImageManager
// Determine the size of the thumbnails to request from the PHCachingImageManager
CGFloat
scale
=
2
.
0
;
CGFloat
scale
=
2
.
0
;
if
([
UIScreen
mainScreen
].
bounds
.
size
.
width
>
600
)
{
if
([
UIScreen
mainScreen
].
bounds
.
size
.
width
>
600
)
{
...
@@ -159,6 +171,10 @@ static CGSize AssetGridThumbnailSize;
...
@@ -159,6 +171,10 @@ static CGSize AssetGridThumbnailSize;
}
}
CGSize
cellSize
=
((
UICollectionViewFlowLayout
*
)
_collectionView
.
collectionViewLayout
).
itemSize
;
CGSize
cellSize
=
((
UICollectionViewFlowLayout
*
)
_collectionView
.
collectionViewLayout
).
itemSize
;
AssetGridThumbnailSize
=
CGSizeMake
(
cellSize
.
width
*
scale
,
cellSize
.
height
*
scale
);
AssetGridThumbnailSize
=
CGSizeMake
(
cellSize
.
width
*
scale
,
cellSize
.
height
*
scale
);
if
(
!
_models
)
{
[
self
fetchAssetModels
];
}
}
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
...
TZImagePickerController/ViewController.m
View file @
541a0a7f
...
@@ -200,7 +200,7 @@
...
@@ -200,7 +200,7 @@
if
(
self
.
maxCountTF
.
text
.
integerValue
<=
0
)
{
if
(
self
.
maxCountTF
.
text
.
integerValue
<=
0
)
{
return
;
return
;
}
}
TZImagePickerController
*
imagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
self
.
maxCountTF
.
text
.
integerValue
columnNumber
:
self
.
columnNumberTF
.
text
.
integerValue
delegate
:
self
pushPhotoPickerVc
:
NO
];
TZImagePickerController
*
imagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
self
.
maxCountTF
.
text
.
integerValue
columnNumber
:
self
.
columnNumberTF
.
text
.
integerValue
delegate
:
self
pushPhotoPickerVc
:
YES
];
#pragma mark - 四类个性化设置,这些参数都可以不传,此时会走默认设置
#pragma mark - 四类个性化设置,这些参数都可以不传,此时会走默认设置
...
...
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