[TIMOB-24249] Ti.UI.iOS.LivePhotoView does not update it's layout when it's livePhoto property is updated
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-12-21T08:57:23.000+0000 |
Affected Version/s | titanium ${PACKAGE_VERSION} |
Fix Version/s | Release 6.1.0 |
Components | iOS |
Labels | n/a |
Reporter | Richard Lustemberg |
Assignee | Hans Knöchel |
Created | 2016-12-21T08:19:53.000+0000 |
Updated | 2017-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];
Updated example (I forgot to complete the Ti classic implementation so that you can run it:
Community PR: https://github.com/appcelerator/titanium_mobile/pull/8707
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