Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-syan-image-picker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenSource
react-native-syan-image-picker
Commits
1cc21f9c
Commit
1cc21f9c
authored
Apr 10, 2018
by
马忠秋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix dismiss not completion
parent
ccd9496f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
46 deletions
+47
-46
RNSyanImagePicker.m
ios/RNSyanImagePicker.m
+47
-46
No files found.
ios/RNSyanImagePicker.m
View file @
1cc21f9c
...
...
@@ -227,55 +227,56 @@ RCT_EXPORT_METHOD(removeAllPhoto) {
}
-
(
void
)
imagePickerController
:
(
UIImagePickerController
*
)
picker
didFinishPickingMediaWithInfo
:
(
NSDictionary
*
)
info
{
[
picker
dismissViewControllerAnimated
:
YES
completion
:
nil
];
NSString
*
type
=
[
info
objectForKey
:
UIImagePickerControllerMediaType
];
if
([
type
isEqualToString
:
@"public.image"
])
{
TZImagePickerController
*
tzImagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
1
delegate
:
nil
];
tzImagePickerVc
.
sortAscendingByModificationDate
=
NO
;
[
tzImagePickerVc
showProgressHUD
];
UIImage
*
image
=
[
info
objectForKey
:
UIImagePickerControllerOriginalImage
];
// save photo and get asset / 保存图片,获取到asset
[[
TZImageManager
manager
]
savePhotoWithImage
:
image
location
:
NULL
completion
:^
(
NSError
*
error
){
if
(
error
)
{
[
tzImagePickerVc
hideProgressHUD
];
NSLog
(
@"图片保存失败 %@"
,
error
);
}
else
{
[[
TZImageManager
manager
]
getCameraRollAlbum
:
NO
allowPickingImage
:
YES
needFetchAssets
:
YES
completion
:^
(
TZAlbumModel
*
model
)
{
[[
TZImageManager
manager
]
getAssetsFromFetchResult
:
model
.
result
allowPickingVideo
:
NO
allowPickingImage
:
YES
completion
:^
(
NSArray
<
TZAssetModel
*>
*
models
)
{
[
tzImagePickerVc
hideProgressHUD
];
TZAssetModel
*
assetModel
=
[
models
firstObject
];
BOOL
isCrop
=
[
self
.
cameraOptions
sy_boolForKey
:
@"isCrop"
];
BOOL
showCropCircle
=
[
self
.
cameraOptions
sy_boolForKey
:
@"showCropCircle"
];
NSInteger
CropW
=
[
self
.
cameraOptions
sy_integerForKey
:
@"CropW"
];
NSInteger
CropH
=
[
self
.
cameraOptions
sy_integerForKey
:
@"CropH"
];
NSInteger
circleCropRadius
=
[
self
.
cameraOptions
sy_integerForKey
:
@"circleCropRadius"
];
NSInteger
quality
=
[
self
.
cameraOptions
sy_integerForKey
:
@"quality"
];
if
(
isCrop
)
{
TZImagePickerController
*
imagePicker
=
[[
TZImagePickerController
alloc
]
initCropTypeWithAsset
:
assetModel
.
asset
photo
:
image
completion
:^
(
UIImage
*
cropImage
,
id
asset
)
{
[
self
invokeSuccessWithResult
:@[[
self
handleImageData
:
cropImage
quality
:
quality
]]];
}];
imagePicker
.
allowCrop
=
isCrop
;
// 裁剪
if
(
showCropCircle
)
{
imagePicker
.
needCircleCrop
=
showCropCircle
;
//圆形裁剪
imagePicker
.
circleCropRadius
=
circleCropRadius
;
//圆形半径
[
picker
dismissViewControllerAnimated
:
YES
completion
:
^
{
NSString
*
type
=
[
info
objectForKey
:
UIImagePickerControllerMediaType
];
if
([
type
isEqualToString
:
@"public.image"
])
{
TZImagePickerController
*
tzImagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
1
delegate
:
nil
];
tzImagePickerVc
.
sortAscendingByModificationDate
=
NO
;
[
tzImagePickerVc
showProgressHUD
];
UIImage
*
image
=
[
info
objectForKey
:
UIImagePickerControllerOriginalImage
];
// save photo and get asset / 保存图片,获取到asset
[[
TZImageManager
manager
]
savePhotoWithImage
:
image
location
:
NULL
completion
:^
(
NSError
*
error
){
if
(
error
)
{
[
tzImagePickerVc
hideProgressHUD
];
NSLog
(
@"图片保存失败 %@"
,
error
);
}
else
{
[[
TZImageManager
manager
]
getCameraRollAlbum
:
NO
allowPickingImage
:
YES
needFetchAssets
:
YES
completion
:^
(
TZAlbumModel
*
model
)
{
[[
TZImageManager
manager
]
getAssetsFromFetchResult
:
model
.
result
allowPickingVideo
:
NO
allowPickingImage
:
YES
completion
:^
(
NSArray
<
TZAssetModel
*>
*
models
)
{
[
tzImagePickerVc
hideProgressHUD
];
TZAssetModel
*
assetModel
=
[
models
firstObject
];
BOOL
isCrop
=
[
self
.
cameraOptions
sy_boolForKey
:
@"isCrop"
];
BOOL
showCropCircle
=
[
self
.
cameraOptions
sy_boolForKey
:
@"showCropCircle"
];
NSInteger
CropW
=
[
self
.
cameraOptions
sy_integerForKey
:
@"CropW"
];
NSInteger
CropH
=
[
self
.
cameraOptions
sy_integerForKey
:
@"CropH"
];
NSInteger
circleCropRadius
=
[
self
.
cameraOptions
sy_integerForKey
:
@"circleCropRadius"
];
NSInteger
quality
=
[
self
.
cameraOptions
sy_integerForKey
:
@"quality"
];
if
(
isCrop
)
{
TZImagePickerController
*
imagePicker
=
[[
TZImagePickerController
alloc
]
initCropTypeWithAsset
:
assetModel
.
asset
photo
:
image
completion
:^
(
UIImage
*
cropImage
,
id
asset
)
{
[
self
invokeSuccessWithResult
:@[[
self
handleImageData
:
cropImage
quality
:
quality
]]];
}];
imagePicker
.
allowCrop
=
isCrop
;
// 裁剪
if
(
showCropCircle
)
{
imagePicker
.
needCircleCrop
=
showCropCircle
;
//圆形裁剪
imagePicker
.
circleCropRadius
=
circleCropRadius
;
//圆形半径
}
else
{
CGFloat
x
=
([[
UIScreen
mainScreen
]
bounds
].
size
.
width
-
CropW
)
/
2
;
CGFloat
y
=
([[
UIScreen
mainScreen
]
bounds
].
size
.
height
-
CropH
)
/
2
;
imagePicker
.
cropRect
=
CGRectMake
(
x
,
y
,
CropW
,
CropH
);
}
[[
self
topViewController
]
presentViewController
:
imagePicker
animated
:
YES
completion
:
nil
];
}
else
{
CGFloat
x
=
([[
UIScreen
mainScreen
]
bounds
].
size
.
width
-
CropW
)
/
2
;
CGFloat
y
=
([[
UIScreen
mainScreen
]
bounds
].
size
.
height
-
CropH
)
/
2
;
imagePicker
.
cropRect
=
CGRectMake
(
x
,
y
,
CropW
,
CropH
);
[
self
invokeSuccessWithResult
:@[[
self
handleImageData
:
image
quality
:
quality
]]];
}
[[
self
topViewController
]
presentViewController
:
imagePicker
animated
:
YES
completion
:
nil
];
}
else
{
[
self
invokeSuccessWithResult
:@[[
self
handleImageData
:
image
quality
:
quality
]]];
}
}];
}];
}
];
}
}
];
}
}
}
];
}
}
];
}
-
(
void
)
imagePickerControllerDidCancel
:
(
UIImagePickerController
*
)
picker
{
...
...
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