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
dab94eaf
Unverified
Commit
dab94eaf
authored
Dec 21, 2017
by
谭真
Committed by
GitHub
Dec 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #702 from izemo/master
block内增加了强引用,防止因对象被释放而带来的异常
parents
e70691b7
bfa91a0b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
35 deletions
+57
-35
TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m
...ler/TZImagePickerController/TZGifPhotoPreviewController.m
+2
-1
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+9
-5
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+22
-14
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
...erController/TZImagePickerController/TZPhotoPreviewCell.m
+8
-5
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
...roller/TZImagePickerController/TZPhotoPreviewController.m
+12
-8
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+4
-2
No files found.
TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m
View file @
dab94eaf
...
...
@@ -56,7 +56,8 @@
_previewView
.
model
=
self
.
model
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
_previewView
setSingleTapGestureBlock
:
^
{
[
weakSelf
signleTapAction
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
signleTapAction
];
}];
[
self
.
view
addSubview
:
_previewView
];
}
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
dab94eaf
...
...
@@ -213,9 +213,11 @@
previewVc
.
currentIndex
=
index
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
previewVc
setDoneButtonClickBlockWithPreviewType
:
^
(
NSArray
<
UIImage
*>
*
photos
,
NSArray
*
assets
,
BOOL
isSelectOriginalPhoto
)
{
[
weakSelf
dismissViewControllerAnimated
:
YES
completion
:
^
{
if
(
weakSelf
.
didFinishPickingPhotosHandle
)
{
weakSelf
.
didFinishPickingPhotosHandle
(
photos
,
assets
,
isSelectOriginalPhoto
);
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
dismissViewControllerAnimated
:
YES
completion
:
^
{
if
(
!
strongSelf
)
return
;
if
(
strongSelf
.
didFinishPickingPhotosHandle
)
{
strongSelf
.
didFinishPickingPhotosHandle
(
photos
,
assets
,
isSelectOriginalPhoto
);
}
}];
}];
...
...
@@ -238,7 +240,8 @@
previewVc
.
currentIndex
=
0
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
previewVc
setDoneButtonClickBlockCropMode
:
^
(
UIImage
*
cropImage
,
id
asset
)
{
[
weakSelf
dismissViewControllerAnimated
:
YES
completion
:
^
{
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
dismissViewControllerAnimated
:
YES
completion
:
^
{
if
(
completion
)
{
completion
(
cropImage
,
asset
);
}
...
...
@@ -367,7 +370,8 @@
// if over time, dismiss HUD automatic
__weak
typeof
(
self
)
weakSelf
=
self
;
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
self
.
timeout
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
[
weakSelf
hideProgressHUD
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
hideProgressHUD
];
});
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
dab94eaf
...
...
@@ -460,10 +460,13 @@ static CGFloat itemMargin = 5;
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
_numberImageView
.
layer
)
weakLayer
=
_numberImageView
.
layer
;
cell
.
didSelectPhotoBlock
=
^
(
BOOL
isSelected
)
{
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
weakSelf
.
navigationController
;
__strong
typeof
(
weakCell
)
strongCell
=
weakCell
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
__strong
typeof
(
weakLayer
)
strongLayer
=
weakLayer
;
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
strongSelf
.
navigationController
;
// 1. cancel select / 取消选择
if
(
isSelected
)
{
weak
Cell
.
selectPhotoButton
.
selected
=
NO
;
strong
Cell
.
selectPhotoButton
.
selected
=
NO
;
model
.
isSelected
=
NO
;
NSArray
*
selectedModels
=
[
NSArray
arrayWithArray
:
tzImagePickerVc
.
selectedModels
];
for
(
TZAssetModel
*
model_item
in
selectedModels
)
{
...
...
@@ -472,20 +475,20 @@ static CGFloat itemMargin = 5;
break
;
}
}
[
weak
Self
refreshBottomToolBarStatus
];
[
strong
Self
refreshBottomToolBarStatus
];
}
else
{
// 2. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
if
(
tzImagePickerVc
.
selectedModels
.
count
<
tzImagePickerVc
.
maxImagesCount
)
{
weak
Cell
.
selectPhotoButton
.
selected
=
YES
;
strong
Cell
.
selectPhotoButton
.
selected
=
YES
;
model
.
isSelected
=
YES
;
[
tzImagePickerVc
.
selectedModels
addObject
:
model
];
[
weak
Self
refreshBottomToolBarStatus
];
[
strong
Self
refreshBottomToolBarStatus
];
}
else
{
NSString
*
title
=
[
NSString
stringWithFormat
:[
NSBundle
tz_localizedStringForKey
:
@"Select a maximum of %zd photos"
],
tzImagePickerVc
.
maxImagesCount
];
[
tzImagePickerVc
showAlertWithTitle
:
title
];
}
}
[
UIView
showOscillatoryAnimationWithLayer
:
weak
Layer
type
:
TZOscillatoryAnimationToSmaller
];
[
UIView
showOscillatoryAnimationWithLayer
:
strong
Layer
type
:
TZOscillatoryAnimationToSmaller
];
};
return
cell
;
}
...
...
@@ -576,9 +579,11 @@ static CGFloat itemMargin = 5;
// 提前定位
__weak
typeof
(
self
)
weakSelf
=
self
;
[[
TZLocationManager
manager
]
startLocationWithSuccessBlock
:
^
(
CLLocation
*
location
,
CLLocation
*
oldLocation
)
{
weakSelf
.
location
=
location
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
location
;
}
failureBlock
:
^
(
NSError
*
error
)
{
weakSelf
.
location
=
nil
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
nil
;
}];
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
...
...
@@ -613,16 +618,19 @@ static CGFloat itemMargin = 5;
__weak
typeof
(
self
)
weakSelf
=
self
;
photoPreviewVc
.
isSelectOriginalPhoto
=
_isSelectOriginalPhoto
;
[
photoPreviewVc
setBackButtonClickBlock
:
^
(
BOOL
isSelectOriginalPhoto
)
{
weakSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
[
weakSelf
.
collectionView
reloadData
];
[
weakSelf
refreshBottomToolBarStatus
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
[
strongSelf
.
collectionView
reloadData
];
[
strongSelf
refreshBottomToolBarStatus
];
}];
[
photoPreviewVc
setDoneButtonClickBlock
:
^
(
BOOL
isSelectOriginalPhoto
)
{
weakSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
[
weakSelf
doneButtonClick
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
[
strongSelf
doneButtonClick
];
}];
[
photoPreviewVc
setDoneButtonClickBlockCropMode
:
^
(
UIImage
*
cropedImage
,
id
asset
)
{
[
weakSelf
didGetAllPhotos
:@[
cropedImage
]
assets
:@[
asset
]
infoArr
:
nil
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
didGetAllPhotos
:@[
cropedImage
]
assets
:@[
asset
]
infoArr
:
nil
];
}];
[
self
.
navigationController
pushViewController
:
photoPreviewVc
animated
:
YES
];
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
View file @
dab94eaf
...
...
@@ -50,13 +50,15 @@
self
.
previewView
=
[[
TZPhotoPreviewView
alloc
]
initWithFrame
:
CGRectZero
];
__weak
typeof
(
self
)
weakSelf
=
self
;
[
self
.
previewView
setSingleTapGestureBlock
:
^
{
if
(
weakSelf
.
singleTapGestureBlock
)
{
weakSelf
.
singleTapGestureBlock
();
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
if
(
strongSelf
.
singleTapGestureBlock
)
{
strongSelf
.
singleTapGestureBlock
();
}
}];
[
self
.
previewView
setImageProgressUpdateBlock
:
^
(
double
progress
)
{
if
(
weakSelf
.
imageProgressUpdateBlock
)
{
weakSelf
.
imageProgressUpdateBlock
(
progress
);
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
if
(
strongSelf
.
imageProgressUpdateBlock
)
{
strongSelf
.
imageProgressUpdateBlock
(
progress
);
}
}];
[
self
addSubview
:
self
.
previewView
];
...
...
@@ -419,7 +421,8 @@
_previewView
=
[[
TZPhotoPreviewView
alloc
]
initWithFrame
:
CGRectZero
];
__weak
typeof
(
self
)
weakSelf
=
self
;
[
_previewView
setSingleTapGestureBlock
:
^
{
[
weakSelf
signleTapAction
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
signleTapAction
];
}];
[
self
addSubview
:
_previewView
];
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
View file @
dab94eaf
...
...
@@ -51,7 +51,6 @@
if
(
!
self
.
models
.
count
)
{
self
.
models
=
[
NSMutableArray
arrayWithArray
:
_tzImagePickerVc
.
selectedModels
];
_assetsTemp
=
[
NSMutableArray
arrayWithArray
:
_tzImagePickerVc
.
selectedAssets
];
self
.
isSelectOriginalPhoto
=
_tzImagePickerVc
.
isSelectOriginalPhoto
;
}
[
self
configCollectionView
];
[
self
configCustomNaviBar
];
...
...
@@ -427,13 +426,17 @@
__weak
typeof
(
_collectionView
)
weakCollectionView
=
_collectionView
;
__weak
typeof
(
photoPreviewCell
)
weakCell
=
photoPreviewCell
;
[
photoPreviewCell
setImageProgressUpdateBlock
:
^
(
double
progress
)
{
weakSelf
.
progress
=
progress
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
__strong
typeof
(
weakTzImagePickerVc
)
strongTzImagePickerVc
=
weakTzImagePickerVc
;
__strong
typeof
(
weakCollectionView
)
strongCollectionView
=
weakCollectionView
;
__strong
typeof
(
weakCell
)
strongCell
=
weakCell
;
strongSelf
.
progress
=
progress
;
if
(
progress
>=
1
)
{
if
(
weakSelf
.
isSelectOriginalPhoto
)
[
weak
Self
showPhotoBytes
];
if
(
weakSelf
.
alertView
&&
[
weakCollectionView
.
visibleCells
containsObject
:
weak
Cell
])
{
[
weakTzImagePickerVc
hideAlertView
:
weak
Self
.
alertView
];
weak
Self
.
alertView
=
nil
;
[
weak
Self
doneButtonClick
];
if
(
strongSelf
.
isSelectOriginalPhoto
)
[
strong
Self
showPhotoBytes
];
if
(
strongSelf
.
alertView
&&
[
strongCollectionView
.
visibleCells
containsObject
:
strong
Cell
])
{
[
strongTzImagePickerVc
hideAlertView
:
strong
Self
.
alertView
];
strong
Self
.
alertView
=
nil
;
[
strong
Self
doneButtonClick
];
}
}
}];
...
...
@@ -441,7 +444,8 @@
cell
.
model
=
model
;
[
cell
setSingleTapGestureBlock
:
^
{
[
weakSelf
didTapPreviewCell
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
didTapPreviewCell
];
}];
return
cell
;
}
...
...
TZImagePickerController/ViewController.m
View file @
dab94eaf
...
...
@@ -362,9 +362,11 @@
// 提前定位
__weak
typeof
(
self
)
weakSelf
=
self
;
[[
TZLocationManager
manager
]
startLocationWithSuccessBlock
:
^
(
CLLocation
*
location
,
CLLocation
*
oldLocation
)
{
weakSelf
.
location
=
location
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
location
;
}
failureBlock
:
^
(
NSError
*
error
)
{
weakSelf
.
location
=
nil
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
nil
;
}];
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
...
...
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