Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image scaled incorrectly on iOS since NS5 and plugin version >3.0.0 #16

Open
FranciZ opened this issue Feb 2, 2019 · 8 comments
Open

Comments

@FranciZ
Copy link

FranciZ commented Feb 2, 2019

While this used to work on iOS, with Nativescript 5 and plugin versions >3.0.0 the image now gets stretched across the whole container and does not respect the aspect ratio of the image.

I'm using

  • Angular 7.1
  • nativescript-image-zoom 3.0.3
  • tns-core-modules 5.1.0
  • tns-ios 5.1.1
@FranciZ FranciZ changed the title Image scaled incorrectly on iOS Image scaled incorrectly on iOS since NS5 and plugin version >3.0.0 Feb 2, 2019
@FranciZ
Copy link
Author

FranciZ commented Feb 2, 2019

I had to set the contentMode to UIViewContentModeScaleAspectFit after the line below for now:

https://github.com/triniwiz/nativescript-image-zoom/blob/master/src/image-zoom.ios.ts#L23

The stretch parameters don't seem to work.

@racknoris
Copy link

@FranciZ Did you clone and used a local version of the plugin? Or changed the existing file inside the node_modules folder?

@FranciZ
Copy link
Author

FranciZ commented Mar 17, 2019

@racknoris Just edited the module in node_modules for now.

@racknoris
Copy link

@FranciZ Ok, so just to be sure, you added:
this._image.contentMode = UIViewContentMode.ScaleAspectFit;, correct?

@FranciZ
Copy link
Author

FranciZ commented Mar 17, 2019

Don't have the project with me right now but I think this is the addition I made:

this._image.contentMode = UIViewContentModeScaleAspectFit;

https://developer.apple.com/documentation/uikit/uiviewcontentmode/uiviewcontentmodescaleaspectfit

@racknoris
Copy link

@FranciZ Ok I did that and it works great, but the picture seems to be not vertically aligned to the center.
Did you encounter this issue?

@3rror404
Copy link

3rror404 commented May 8, 2019

If you don't wish to edit the plugin code, the following seems to work for me.

let image = page.getViewById('image'); // Your <ui:ImageZoom /> element
let nativeView = image.nativeView.subviews[0]; // UIScrollView/UIImageView
nativeView.contentMode = UIViewContentModeScaleAspectFit;

yoat added a commit to yoat/nativescript-image-zoom that referenced this issue Jun 3, 2019
@anki247
Copy link

anki247 commented Oct 10, 2019

It would be nice to release this merged change 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants