Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18245] Ti.Media.takeScreenshot() does not render the selected iOS TabbedBar element

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-02-11T16:22:36.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.0.0
ComponentsiOS
Labelsios, module_media, qe-manualtest
ReporterMalcolm Hollingsworth
AssigneeChee Kiat Ng
Created2014-12-16T14:46:47.000+0000
Updated2015-02-17T05:36:48.000+0000

Description

The method *Ti.Media.takeScreenshot()* does not render the selected iOS TabbedBar element. If an *iOS TabbedBar* is displayed on a device with at least one selected entry visible the text of the selected entry will NOT render when the *takeScreenshot* method is called and the resulting image is displayed or stored in the file system. The problem exists on Ti SDK 3.4.1 and Ti SDK 3.5.0 beta on iOS simulators 7.1 and 8.1 in all of the devices size variations.
var win = Ti.UI.createWindow({
    backgroundColor: 'red'
});
var fileName = 'testme.png';
var bb1 = Titanium.UI.createTabbedBar({
    labels: ['One', 'Two', 'Three'],
    backgroundColor: '#336699',
    top: 50,
    style: Titanium.UI.iPhone.SystemButtonStyle.BAR,
    height: 25,
    width: 200,
    bubble: false
});
win.add(bb1);
win.addEventListener('click', function(e) {
    Ti.Media.takeScreenshot(function(e) {
        var file = Ti.Filesystem.getFile(Ti.Filesystem.getTempDirectory(), fileName);
        Ti.API.info(fileName + ': ' + file.resolve());
        file.write(e.media);
        file = null;
    });
});
win.add(bb1);
The problem occurs using both Alloy or non-alloy - obvious but ruled out anyway. Confirmation (and simple code snippet) provided by Stephen Feather.

Attachments

FileDateSize
alloyversion.png2014-12-16T14:46:47.000+00008252
testme.png2014-12-16T14:46:47.000+000022040

Comments

  1. Chee Kiat Ng 2015-02-11

    Updated sample code here:

       var win = Ti.UI.createWindow({
           backgroundColor: 'red'
       });
       var fileName = 'testme.png';
       var bb1 = Titanium.UI.iOS.createTabbedBar({
           labels: ['One', 'Two', 'Three'],
           backgroundColor: '#336699',
           top: 50,
           height: 25,
           width: 200,
           bubble: false
       });
       
       win.add(bb1);
       win.addEventListener('dblclick', function(e) {
           Ti.Media.takeScreenshot(function(e) {
               var file = Ti.Filesystem.getFile(Ti.Filesystem.getTempDirectory(), fileName);
               Ti.API.info(fileName + ': ' + file.resolve());
               file.write(e.media);
               file = null;
           });
       });
       win.open();
       
       

    Changes made:

    - Replace deprecated Ti.UI.tabbedbar with Ti.UI.iOS.tabbedbar. - Removed deprecated Ti.UI.iPhone.SystemButtonStyle.BAR. - Used dblclick instead of click event to capture screenshot
  2. Chee Kiat Ng 2015-02-11

    PR Here: https://github.com/appcelerator/titanium_mobile/pull/6638
  3. Satyam Sekhri 2015-02-17

    The selected tab in tabbed bar is rendered in the screenshot through Ti.Media.takeScreenshot Verified on: Appc Studio: 4.0.0.201502111039 Titanium SDK: 4.0.0.v20150216083136 Xcode: 6.1, 6.2 beta Device: iOS Simulator v8.1, v8.2 beta, iPhone 4 (v7.1), iPhone 5S (v8.1)

JSON Source