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
3c805dad
Commit
3c805dad
authored
Dec 21, 2017
by
zyy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
防止对象被释放而又用weak指针调用所带来的异常
parent
d402958e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
30 deletions
+50
-30
TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m
...ler/TZImagePickerController/TZGifPhotoPreviewController.m
+2
-1
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+2
-1
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
-7
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+4
-2
No files found.
TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m
View file @
3c805dad
...
@@ -56,7 +56,8 @@
...
@@ -56,7 +56,8 @@
_previewView
.
model
=
self
.
model
;
_previewView
.
model
=
self
.
model
;
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
_previewView
setSingleTapGestureBlock
:
^
{
[
_previewView
setSingleTapGestureBlock
:
^
{
[
weakSelf
signleTapAction
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
signleTapAction
];
}];
}];
[
self
.
view
addSubview
:
_previewView
];
[
self
.
view
addSubview
:
_previewView
];
}
}
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
3c805dad
...
@@ -370,7 +370,8 @@
...
@@ -370,7 +370,8 @@
// if over time, dismiss HUD automatic
// if over time, dismiss HUD automatic
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
self
.
timeout
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
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 @
3c805dad
...
@@ -460,10 +460,13 @@ static CGFloat itemMargin = 5;
...
@@ -460,10 +460,13 @@ static CGFloat itemMargin = 5;
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
_numberImageView
.
layer
)
weakLayer
=
_numberImageView
.
layer
;
__weak
typeof
(
_numberImageView
.
layer
)
weakLayer
=
_numberImageView
.
layer
;
cell
.
didSelectPhotoBlock
=
^
(
BOOL
isSelected
)
{
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 / 取消选择
// 1. cancel select / 取消选择
if
(
isSelected
)
{
if
(
isSelected
)
{
weak
Cell
.
selectPhotoButton
.
selected
=
NO
;
strong
Cell
.
selectPhotoButton
.
selected
=
NO
;
model
.
isSelected
=
NO
;
model
.
isSelected
=
NO
;
NSArray
*
selectedModels
=
[
NSArray
arrayWithArray
:
tzImagePickerVc
.
selectedModels
];
NSArray
*
selectedModels
=
[
NSArray
arrayWithArray
:
tzImagePickerVc
.
selectedModels
];
for
(
TZAssetModel
*
model_item
in
selectedModels
)
{
for
(
TZAssetModel
*
model_item
in
selectedModels
)
{
...
@@ -472,20 +475,20 @@ static CGFloat itemMargin = 5;
...
@@ -472,20 +475,20 @@ static CGFloat itemMargin = 5;
break
;
break
;
}
}
}
}
[
weak
Self
refreshBottomToolBarStatus
];
[
strong
Self
refreshBottomToolBarStatus
];
}
else
{
}
else
{
// 2. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
// 2. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
if
(
tzImagePickerVc
.
selectedModels
.
count
<
tzImagePickerVc
.
maxImagesCount
)
{
if
(
tzImagePickerVc
.
selectedModels
.
count
<
tzImagePickerVc
.
maxImagesCount
)
{
weak
Cell
.
selectPhotoButton
.
selected
=
YES
;
strong
Cell
.
selectPhotoButton
.
selected
=
YES
;
model
.
isSelected
=
YES
;
model
.
isSelected
=
YES
;
[
tzImagePickerVc
.
selectedModels
addObject
:
model
];
[
tzImagePickerVc
.
selectedModels
addObject
:
model
];
[
weak
Self
refreshBottomToolBarStatus
];
[
strong
Self
refreshBottomToolBarStatus
];
}
else
{
}
else
{
NSString
*
title
=
[
NSString
stringWithFormat
:[
NSBundle
tz_localizedStringForKey
:
@"Select a maximum of %zd photos"
],
tzImagePickerVc
.
maxImagesCount
];
NSString
*
title
=
[
NSString
stringWithFormat
:[
NSBundle
tz_localizedStringForKey
:
@"Select a maximum of %zd photos"
],
tzImagePickerVc
.
maxImagesCount
];
[
tzImagePickerVc
showAlertWithTitle
:
title
];
[
tzImagePickerVc
showAlertWithTitle
:
title
];
}
}
}
}
[
UIView
showOscillatoryAnimationWithLayer
:
weak
Layer
type
:
TZOscillatoryAnimationToSmaller
];
[
UIView
showOscillatoryAnimationWithLayer
:
strong
Layer
type
:
TZOscillatoryAnimationToSmaller
];
};
};
return
cell
;
return
cell
;
}
}
...
@@ -576,9 +579,11 @@ static CGFloat itemMargin = 5;
...
@@ -576,9 +579,11 @@ static CGFloat itemMargin = 5;
// 提前定位
// 提前定位
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[[
TZLocationManager
manager
]
startLocationWithSuccessBlock
:
^
(
CLLocation
*
location
,
CLLocation
*
oldLocation
)
{
[[
TZLocationManager
manager
]
startLocationWithSuccessBlock
:
^
(
CLLocation
*
location
,
CLLocation
*
oldLocation
)
{
weakSelf
.
location
=
location
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
location
;
}
failureBlock
:
^
(
NSError
*
error
)
{
}
failureBlock
:
^
(
NSError
*
error
)
{
weakSelf
.
location
=
nil
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
nil
;
}];
}];
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
...
@@ -613,16 +618,19 @@ static CGFloat itemMargin = 5;
...
@@ -613,16 +618,19 @@ static CGFloat itemMargin = 5;
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
photoPreviewVc
.
isSelectOriginalPhoto
=
_isSelectOriginalPhoto
;
photoPreviewVc
.
isSelectOriginalPhoto
=
_isSelectOriginalPhoto
;
[
photoPreviewVc
setBackButtonClickBlock
:
^
(
BOOL
isSelectOriginalPhoto
)
{
[
photoPreviewVc
setBackButtonClickBlock
:
^
(
BOOL
isSelectOriginalPhoto
)
{
weakSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
weakSelf
.
collectionView
reloadData
];
strongSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
[
weakSelf
refreshBottomToolBarStatus
];
[
strongSelf
.
collectionView
reloadData
];
[
strongSelf
refreshBottomToolBarStatus
];
}];
}];
[
photoPreviewVc
setDoneButtonClickBlock
:
^
(
BOOL
isSelectOriginalPhoto
)
{
[
photoPreviewVc
setDoneButtonClickBlock
:
^
(
BOOL
isSelectOriginalPhoto
)
{
weakSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
weakSelf
doneButtonClick
];
strongSelf
.
isSelectOriginalPhoto
=
isSelectOriginalPhoto
;
[
strongSelf
doneButtonClick
];
}];
}];
[
photoPreviewVc
setDoneButtonClickBlockCropMode
:
^
(
UIImage
*
cropedImage
,
id
asset
)
{
[
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
];
[
self
.
navigationController
pushViewController
:
photoPreviewVc
animated
:
YES
];
}
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
View file @
3c805dad
...
@@ -50,13 +50,15 @@
...
@@ -50,13 +50,15 @@
self
.
previewView
=
[[
TZPhotoPreviewView
alloc
]
initWithFrame
:
CGRectZero
];
self
.
previewView
=
[[
TZPhotoPreviewView
alloc
]
initWithFrame
:
CGRectZero
];
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
self
.
previewView
setSingleTapGestureBlock
:
^
{
[
self
.
previewView
setSingleTapGestureBlock
:
^
{
if
(
weakSelf
.
singleTapGestureBlock
)
{
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
weakSelf
.
singleTapGestureBlock
();
if
(
strongSelf
.
singleTapGestureBlock
)
{
strongSelf
.
singleTapGestureBlock
();
}
}
}];
}];
[
self
.
previewView
setImageProgressUpdateBlock
:
^
(
double
progress
)
{
[
self
.
previewView
setImageProgressUpdateBlock
:
^
(
double
progress
)
{
if
(
weakSelf
.
imageProgressUpdateBlock
)
{
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
weakSelf
.
imageProgressUpdateBlock
(
progress
);
if
(
strongSelf
.
imageProgressUpdateBlock
)
{
strongSelf
.
imageProgressUpdateBlock
(
progress
);
}
}
}];
}];
[
self
addSubview
:
self
.
previewView
];
[
self
addSubview
:
self
.
previewView
];
...
@@ -419,7 +421,8 @@
...
@@ -419,7 +421,8 @@
_previewView
=
[[
TZPhotoPreviewView
alloc
]
initWithFrame
:
CGRectZero
];
_previewView
=
[[
TZPhotoPreviewView
alloc
]
initWithFrame
:
CGRectZero
];
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
_previewView
setSingleTapGestureBlock
:
^
{
[
_previewView
setSingleTapGestureBlock
:
^
{
[
weakSelf
signleTapAction
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
signleTapAction
];
}];
}];
[
self
addSubview
:
_previewView
];
[
self
addSubview
:
_previewView
];
}
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
View file @
3c805dad
...
@@ -427,13 +427,17 @@
...
@@ -427,13 +427,17 @@
__weak
typeof
(
_collectionView
)
weakCollectionView
=
_collectionView
;
__weak
typeof
(
_collectionView
)
weakCollectionView
=
_collectionView
;
__weak
typeof
(
photoPreviewCell
)
weakCell
=
photoPreviewCell
;
__weak
typeof
(
photoPreviewCell
)
weakCell
=
photoPreviewCell
;
[
photoPreviewCell
setImageProgressUpdateBlock
:
^
(
double
progress
)
{
[
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
(
progress
>=
1
)
{
if
(
weakSelf
.
isSelectOriginalPhoto
)
[
weak
Self
showPhotoBytes
];
if
(
strongSelf
.
isSelectOriginalPhoto
)
[
strong
Self
showPhotoBytes
];
if
(
weakSelf
.
alertView
&&
[
weakCollectionView
.
visibleCells
containsObject
:
weak
Cell
])
{
if
(
strongSelf
.
alertView
&&
[
strongCollectionView
.
visibleCells
containsObject
:
strong
Cell
])
{
[
weakTzImagePickerVc
hideAlertView
:
weak
Self
.
alertView
];
[
strongTzImagePickerVc
hideAlertView
:
strong
Self
.
alertView
];
weak
Self
.
alertView
=
nil
;
strong
Self
.
alertView
=
nil
;
[
weak
Self
doneButtonClick
];
[
strong
Self
doneButtonClick
];
}
}
}
}
}];
}];
...
@@ -441,7 +445,8 @@
...
@@ -441,7 +445,8 @@
cell
.
model
=
model
;
cell
.
model
=
model
;
[
cell
setSingleTapGestureBlock
:
^
{
[
cell
setSingleTapGestureBlock
:
^
{
[
weakSelf
didTapPreviewCell
];
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
didTapPreviewCell
];
}];
}];
return
cell
;
return
cell
;
}
}
...
...
TZImagePickerController/ViewController.m
View file @
3c805dad
...
@@ -362,9 +362,11 @@
...
@@ -362,9 +362,11 @@
// 提前定位
// 提前定位
__weak
typeof
(
self
)
weakSelf
=
self
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[[
TZLocationManager
manager
]
startLocationWithSuccessBlock
:
^
(
CLLocation
*
location
,
CLLocation
*
oldLocation
)
{
[[
TZLocationManager
manager
]
startLocationWithSuccessBlock
:
^
(
CLLocation
*
location
,
CLLocation
*
oldLocation
)
{
weakSelf
.
location
=
location
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
location
;
}
failureBlock
:
^
(
NSError
*
error
)
{
}
failureBlock
:
^
(
NSError
*
error
)
{
weakSelf
.
location
=
nil
;
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
location
=
nil
;
}];
}];
UIImagePickerControllerSourceType
sourceType
=
UIImagePickerControllerSourceTypeCamera
;
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