Removed 'screen' option from snapshot API

Summary:Unfortunately the 'screen' option in the `UIManager.takeSnapshot` API appears to work only on the iOS simulator, not on an actual device.

This diff removes the 'screen' option until a solution can be found that works on the device.

(Taking a snapshot of the window still works fine - it just won't include the status bar, etc.)

Reviewed By: javache

Differential Revision: D2971091

fb-gh-sync-id: 026b9d4eb2f59f686f58c18a16381ff325df612b
shipit-source-id: 026b9d4eb2f59f686f58c18a16381ff325df612b
This commit is contained in:
Nick Lockwood 2016-02-24 09:05:28 -08:00 коммит произвёл facebook-github-bot-5
Родитель f538032888
Коммит 4b4455f827
3 изменённых файлов: 8 добавлений и 10 удалений

Просмотреть файл

@ -44,7 +44,7 @@ var ScreenshotExample = React.createClass({
takeScreenshot() {
UIManager
.takeSnapshot('screen', {format: 'jpeg', quality: 0.8}) // See UIManager.js for options
.takeSnapshot('window', {format: 'jpeg', quality: 0.8}) // See UIManager.js for options
.then((uri) => this.setState({uri}))
.catch((error) => alert(error));
}

Просмотреть файл

@ -50,8 +50,8 @@ const _takeSnapshot = UIManager.takeSnapshot;
* will be stored in a temporary file that will only exist for as long as the
* app is running.
*
* The `view` argument can be the literal string `screen` or `window` if you
* want to capture the entire screen, or it can be a reference to a specific
* The `view` argument can be the literal string `window` if you want to
* capture the entire window, or it can be a reference to a specific
* React Native component.
*
* The `options` argument may include:
@ -63,7 +63,7 @@ const _takeSnapshot = UIManager.takeSnapshot;
* @platform ios
*/
UIManager.takeSnapshot = async function(
view ?: 'screen' | 'window' | ReactElement | number,
view ?: 'window' | ReactElement | number,
options ?: {
width ?: number;
height ?: number;
@ -75,8 +75,8 @@ UIManager.takeSnapshot = async function(
console.warn('UIManager.takeSnapshot is not available on this platform');
return;
}
if (typeof view !== 'number' && view !== 'screen' && view !== 'window') {
view = findNodeHandle(view) || 'screen';
if (typeof view !== 'number' && view !== 'window') {
view = findNodeHandle(view) || 'window';
}
return _takeSnapshot(view, options);
};

Просмотреть файл

@ -1191,9 +1191,7 @@ RCT_EXPORT_METHOD(takeSnapshot:(id /* NSString or NSNumber */)target
// Get view
UIView *view;
if (target == nil || [target isEqual:@"screen"]) {
view = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:YES];
} else if ([target isEqual:@"window"]) {
if (target == nil || [target isEqual:@"window"]) {
view = RCTKeyWindow();
} else if ([target isKindOfClass:[NSNumber class]]) {
view = viewRegistry[target];
@ -1217,7 +1215,7 @@ RCT_EXPORT_METHOD(takeSnapshot:(id /* NSString or NSNumber */)target
UIGraphicsEndImageContext();
if (!success || !image) {
reject(RCTErrorUnspecified, @"Failed to capture view snapshot", nil);
reject(RCTErrorUnspecified, @"Failed to capture view snapshot.", nil);
return;
}