Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24249] Ti.UI.iOS.LivePhotoView does not update it's layout when it's livePhoto property is updated

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-12-21T08:57:23.000+0000
Affected Version/stitanium ${PACKAGE_VERSION}
Fix Version/sRelease 6.1.0
ComponentsiOS
Labelsn/a
ReporterRichard Lustemberg
AssigneeHans Knöchel
Created2016-12-21T08:19:53.000+0000
Updated2017-01-25T00:01:58.000+0000

Description

If a Ti.UI.iOS.LivePhotoView is instantiated without the livePhoto property set, and later it is set (ie, after an http request) , the view size remains at 0x0 pixels instead of updating.
var window = Ti.UI.createWindow();
var livePhotoView = Ti.UI.iOS.createLivePhotoView();
window.add(livePhotoView);
function openGallery() {
    Ti.Media.openPhotoGallery({
        mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO, Ti.Media.MEDIA_TYPE_LIVEPHOTO],
        success: function(e) {
            var livePhoto = e.livePhoto // Live photo of type Ti.UI.iOS.LivePhoto

            if (livePhoto) {
                

                
             livePhotoView.livePhoto = livePhoto;//livePhotoView will remain invisible until some                   gesture triggers relayout.
            livePhotoView.width = Ti.UI.FILL;//this is a workaround to make the view recalculate it's size
            }
        }
    });
}
The Titanium Classic example let's you reproduce the issue, allthough it is in Alloy where it becomes more relevant. As a workaround you may reset the view width so that the relayout method is invoked on the view proxy. The issue can be solved in the native sdk as follows:
-(void)setLivePhoto_:(id)arg
{
    ENSURE_UI_THREAD(setLivePhoto_, arg);
    ENSURE_TYPE(arg, TiUIiOSLivePhoto);
    
    PHLivePhoto *livePhoto = [arg livePhoto];
    
    autoWidth = livePhoto.size.width;
    autoHeight = livePhoto.size.height;
    
    [[self livePhotoView] setLivePhoto:livePhoto];    
    [(TiViewProxy*)self.proxy relayout];
    
}
or overriding and making public the relayout method on TiUIiOSLivePhotoViewProxy.h & TiUIiOSLivePhotoViewProxy.m and doing instead:
 [self.proxy relayout];

Comments

  1. Richard Lustemberg 2016-12-21

    Updated example (I forgot to complete the Ti classic implementation so that you can run it:
       var window = Ti.UI.createWindow();
       var livePhotoView = Ti.UI.iOS.createLivePhotoView();
       window.add(livePhotoView);
       var button = Ti.UI.createButton({title:'import photo', width:Ti.UI.SIZE, height: Ti.UI.SIZE, bottom: '10dp', zIndex:10});
       button.addEventListener('click',openGallery);
       window.add(button);
       window.open();
       function openGallery() {
         Ti.Media.openPhotoGallery({
         mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO, Ti.Media.MEDIA_TYPE_LIVEPHOTO],
         success: function(e) {
           var livePhoto = e.livePhoto // Live photo of type Ti.UI.iOS.LivePhoto
           if (livePhoto) { 
             livePhotoView.livePhoto = livePhoto;//livePhotoView will remain invisible until some
             livePhotoView.width = Ti.UI.FILL;//this is a workaround to make the view recalculate it's size
             }
           }
        });
       }
       
  2. Hans Knöchel 2016-12-21

    Community PR: https://github.com/appcelerator/titanium_mobile/pull/8707
  3. Lee Morris 2017-01-25

    Can validate this ticket as fixed, this was tested on; iPhone 7 MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.1 GA and 6.1.0.v20170124071525 Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source