Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Shilling committed Sep 21, 2015
1 parent bd9ef4f commit 5b1cc78
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Example;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -515,6 +516,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Example;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand Down
17 changes: 12 additions & 5 deletions Example/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@ class Example extends React.Component {
takePhotoButtonHidden: false,
chooseFromLibraryButtonTitle: 'Choose from Library...',
chooseFromLibraryButtonHidden: false,
returnBase64Image: true,
returnBase64Image: false,
returnIsVertical: false,
quality: 0.2
};

UIImagePickerManager.showImagePicker(options, (type, response) => {
console.log(type);
if (type !== 'cancel') {
const source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true};
UIImagePickerManager.showImagePicker(options, (responseType, response) => {
console.log(`Response Type = ${responseType}`);

if (responseType !== 'cancel') {
let source;
if (responseType === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string
source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true};
} else { // Selected from library - response is the URI to the local file asset
source = {uri: response.replace('file://', ''), isStatic: true};
}

this.setState({
avatarSource: source
});
Expand Down

0 comments on commit 5b1cc78

Please sign in to comment.