Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17662] iOS8: Feature Request to do not allow the CameraPreview to rotate

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-01-23T19:28:04.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.4.0, Release 3.5.0
ComponentsiOS
Labelsmodule_media, usability
ReporterEduardo Gomez
AssigneeJon Alter
Created2014-09-09T20:13:50.000+0000
Updated2015-01-26T17:36:13.000+0000

Description

Feature Request

Feature Request to do not allow the CameraPreview to rotate. Add the following method inside @implementation TiImagePickerController
- (BOOL)shouldAutorotate
{
    return NO;
}
- https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/MediaModule.m#L65

Sample code

var win = Ti.UI.createWindow({
    backgroundColor: 'white'
});
 
var button = Ti.UI.createButton({
    title: 'Open',
    top: 50,
    left: 10,
    right: 10,
    height: 50
});
 
win.add(button);
 
win.open();
 
button.addEventListener('click', function() {
    Ti.API.info('click');
    Ti.Media.showCamera({
        success: success,
        error: error,
        saveToPhotoGallery: false,
        allowEditing: false,
        mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
        showControls: true,
        autohide: false
    });
 
    function success(e) {
        Ti.API.info('Success');
    }
 
    function error(e) {
        Ti.API.info('Error');
    }
});

Comments

  1. Eduardo Gomez 2014-09-09

    FYI [~aleard].
  2. Alan Leard 2014-09-09

    I think we want this to be added as a boolean property so the developer can set the property to yes or no at their discretion.
       Ti.Media.showCamera({
               autoRotate:false
       });
       
  3. Jon Alter 2014-09-11

  4. Pedro Enrique 2014-09-11

    PRs merged
  5. Olga Romero 2014-09-12

    Tested environment Mac osx 10.9.4 Maverics Appcelerator Studio, build: 3.4.0.201409112242 Titanium SDK, build: 3.4.0.v20140912120914 acs@1.0.16 alloy 1.5.0-rc install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0-rc2 titanium-code-processor@1.1.1 Xcode6 Device: iPad Air iOS8 The camera opens in the current orientation but does not once it is open
  6. Radamantis Torres-Lechuga 2014-09-16

    Using the iOS 8 GM, iOS 8 GM SDK, and the 3.4.0.v20140916131632 TiSDK if you leave the iPad flat on the desk and click launch camera, it shows rotated sideways with the black bars present. Steps to reproduce: 1. Build app with iOS8 SDK & TiSDK 3.4.0.v20140916131632, install on iOS 8 device. 2. Pick up the device and rotate it to landscape orientation (Home button on Right) <- This is key, it seems in portrait this issue does not occur 3. Lay the device flat on the desk 4. Launch the app, then launch image capture by clicking the image capture button. 5. Notice that the image shown is sideways and there are black bars present. If this does not occur close the image capture and repeat steps 3-4 leaving the device flat on the desk. 6. Close the camera viewfinder 7. Pick the ipad up off your desk 8. Click the image capture button. 9. Notice that the viewfinder appears correctly. It should appear like this when its flat on the desk.
  7. Mathieu Bernard 2015-01-20

    On an iPhone 5 with *iOS 8.1.1* using the *3.4.0.GA* Titanium SDK and the following code :
       Titanium.Media.showCamera({
       	success: function(event) {
       		Ti.API.info('PHOTO');
       	},
       	cancel: function() {
       		Ti.API.info('CANCEL');
       	},
       	error: function() {
       		Ti.API.error('ERROR');
       	},
       	autorotate: false,
       	mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
       });
       
    It seems that the camera still rotates because the icons (flash and front/rear camera) rotate. When debugging the objective-c code in XCode, the shouldAutoRotate method from TiImagePickerController is called and the autorotate property value is *NO*. Is there anything wrong with the code or is the feature correctly working ?
  8. Jon Alter 2015-01-23

    Hi [~itsbrnrd], The behavior you are seeing is expected. Apple does not allow us to control the icons rotating.
  9. Jon Alter 2015-01-23

    Reopening to fix typo
  10. Mathieu Bernard 2015-01-26

    Hi [~jalter] and thanks for your quick answer. I understand that the icons cannot be controlled by the autorotate property. However, I don't see any difference in the code I wrote above with the autorotate property set to true or false. What I'm trying to achieve is to force the camera in portait (only) and I thought this property would help me do that. Am I wrong ?
  11. Jon Alter 2015-01-26

    [~itsbrnrd] This property is for iPad apps only. Changing this on an iphone app will have no affect. See the documentation here: http://docs.appcelerator.com/titanium/latest/#!/api/CameraOptionsType-property-autorotate

JSON Source