[AC-1079] Unable to open the camera from a popover on iOS8 with SDK 3.4.0 RC
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Cannot Reproduce |
Resolution Date | 2015-08-28T03:18:01.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | TCSupportTriage |
Reporter | Ivo |
Assignee | Mostafizur Rahman |
Created | 2014-09-26T09:50:16.000+0000 |
Updated | 2016-03-08T07:37:25.000+0000 |
Description
While trying out the release candidate of SDK 3.4.0 we noticed that one of our features which opens the device camera by pressing a button in a popover does not work anymore. This is only reproducible when running our app built with 3.4.0RC SDK on a device that has iOS 8.0 installed.
After doing some investigation, we've discovered that this might have something to do with a window being modal. Below you can find a code snipped that illustrates the problem. There are 2 buttons, one opening the camera and other opening a modal window in the popover. While the camera problem can be only reproduced on a device (because of the hardware constraints), the issue with the modal window can be also reproduced on the simulator.
(function() {
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
var view = Ti.UI.createView();
var button = Ti.UI.createButton({
title : "Open Popover",
bottom : 10
});
button.addEventListener('click', function(e) {
popover.show({
view : button
});
});
// popover construction
var openCameraBtn = Ti.UI.createButton({
title : "Open Camera",
top : 50
});
openCameraBtn.addEventListener('click', function(e) {
popover.hide();
openCamera();
});
var openAnotherWindowBtn = Ti.UI.createButton({
title : "Open Another Window",
top : 150
});
openAnotherWindowBtn.addEventListener('click', function(e) {
popover.hide();
openModalWindow();
});
// popover content window
var contentWindow = Ti.UI.createWindow({
backgroundColor : 'green',
title : 'Content Window',
width : 250,
height : 500
});
contentWindow.add(openCameraBtn);
contentWindow.add(openAnotherWindowBtn);
var popover = Ti.UI.iPad.createPopover({
width : 250,
height : 500,
contentView : Ti.UI.iOS.createNavigationWindow({
window : contentWindow
})
});
popover.addEventListener('hide', function() {
// if camera/modal window is opened here everything works OK
});
view.add(button);
win.add(view);
win.open();
function openCamera() {
Titanium.Media.showCamera({
success : function(event) {
alert('Success!');
},
cancel : function() {
alert('Cancel!');
},
error : function(error) {
alert('Error occured!');
},
saveToPhotoGallery : false,
allowEditing : false,
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});
}
function openModalWindow() {
var win = Ti.UI.createWindow({
backgroundColor : 'orange',
modal : true
});
var btn = Ti.UI.createButton({
title : "Close Window",
});
btn.addEventListener('click', function() {
win.close();
});
win.add(btn);
win.open();
}
})();
In the console warnings like the ones below show up:
Warning: Attempt to present <TiViewController: 0x16dc3830> on <TiViewController: 0x16db6030> whose view is not in the window hierarchy!
Warning: Attempt to present <TiImagePickerController: 0x170e0400> on <TiViewController: 0x16deca60> whose view is not in the window hierarchy!
There is a workaround for the above problem by using a mechanism that will open the camera/modal window in the 'hide' event listener registered on the popover. However we doubt that it is intended to be used like that.
Hello, We tested the issue you reported. And we can open the camera from a popover on iOS 8 with this following environment. *Result:* Not a platform. So I recommend you upgrade studio and SDK version to the latest build and let us know if you get the same warnings again. *Steps To Test* 1. Paste that code in app.js file. 2. Then run with the testing environment. *Testing Environment:* Command-Line Interface, version 4.1.2, Ti SDK: 4.1.0.GA, iOS version: iPad mini (v8.1.1), OS X Version: 10.10.4, Appcelerator Studio: 4.1.1 *Test code* Reporter's Test Code Thanks.