how to replace Image in Lottie animation at runtime in iOS - ios

iOS: I am unable to dynamically change only a specific image in my JSON file. People recommend using BundleImageProvider but it's of no use because there is no way to provide the key for which I want to replace the image.
the android counterpart for the same is updateBitmap but can't find anything in iOS.

Try this:
before start new animation - .pause()
YourAnimation.animation = Animation.named(newAnimationJsonName)
after change animation - .play()

Related

Nativescript Mediafilepicker customizing DKImagePickerController UI

I'm currently using Nativescript-Mediafilepicker plugin to handle image selection and also capturing image from camera in iOS. In ns mediafilepicker docs , i can see that it is using DKImagePickerController native libraries to handle the image selection and In the DKImagePickerController docs, i can see there is an option to customize the UI (CustomUIDelegate).
Is there any possible way to do the same with Nativescript? I wish to customize the camera icon in the image picker gallery. In the DKImagePickerController CustomUIDelegate doc, i can see it is using DKAssetGroupDetailBaseCell to achieve the customization. How can i do this in Nativescript Angular?
Short answer: you cannot do it easily.
Long Answer
You need to override methods since the plugin you are referring to does not expose APIs to modify the icon.
I have tried modifying it myself and I found out modifying the original plugin source code. I can give you hints on what you would have to do based on the understanding I have put in during the last few hours.
Create your custom MediaPicker
class MyMediaPicker extends Mediafilepicker {
...
}
Extend and copy the original openImagePicker method.
As you can see in the original source code, you have access to the picker, but you need to create a custom iOS delegate that handles the task of getting the UIImage for the camera.... This last task is painful, since the DK plugin guy created a custom class to refer to the Camera Cell that you now have to modify as well.
Once you modify (1) the picker plugin method, (2) the internal DK picker delegate, and (3) created a custom CameraCell. You should be able to modify that camera icon.
Here are some useful links:
https://github.com/jibon57/nativescript-mediafilepicker
https://github.com/zhangao0086/DKImagePickerController/blob/e61f49bda664e41dafd3c06174ae0cd1eccda236/Sources/DKImagePickerController/DKImagePickerController.swift
https://github.com/zhangao0086/DKImagePickerController/blob/e61f49bda664e41dafd3c06174ae0cd1eccda236/Sources/DKImagePickerController/Resource/DKImagePickerControllerResource.swift

Get all elements in the view of iphone app using xcode

I am trying to take screenshot of every screen during iphone app automation on a simulator. Along with the screenshot I also want to extract all strings in the that particular view before taking a screenshot using xcode. Is there a way to do that? Purpose is to send these screenshots and strings for validation to another tool.
This can be done using Web Driver Agent(WDA) provided by facebook. It does provide all the functionalities you need for your app.
Here is link to github repo for it:
https://github.com/facebook/WebDriverAgent
Please have a look at it. It might help you achieving your goal.
If you are using the XCUITest framework for your automation, you can use XCUIScreen.main.screenshot() to get a screenshot of the current state.
To fetch all text currently on screen you can use XCUIApplication().descendants(matching: .textField) or .buttons or .any or whatever you expect to be on the screen, and extract the text from the element
let descendants = XCUIApplication().descendants(matching: .textField)
foreach descendant in descendants { descendant.label /*do something*/ }
You need to set an Accessibility Identifier on the view elements for this to work.

Programatically Set UIImage Animation with WatchKit

I can't seem to figure out how to programmatically set a new image, via the outlet, and make it start animating.
Sequence
zeroEntering0.png
zeroEntering1.png
zeroEntering2.png
zeroEntering3.png
zeroEntering4.png
I imported the sequence of images into the Image.xcassets inside the WatchKit App
I can set the image in the interface builder to "zeroEntering" and set animating to "Yes" and it works correctly.
However, I want something more dynamic, I need a button press to choose a new animation sequence and start it off. If I try and set the image programmatically using the same name from the interface builder, the UIImage is nil.
What naming convention should I use when programmatically setting the UIImage? "zeroEntering", "zeroEntering0", "zeroEntering.png" or "zeroEntering0.png"
I tried using the two non-nil options and the image did not animate and went black.
The answer is subtle and definitely got my wheels spinning for too long.
According to this beautiful article,
You should use setImageNamed(:) when the image you want to display is either cached on the watch on is in an asset catalog in the watch app’s bundle, and use setImage(:) when the image isn’t cached — this will transfer the image data to the Apple Watch over the air!
So, I kept my images in the assets catalog on the watch app, and switch to use,
[self.testImage setImageNamed:#"zeroEntering"];
[self.testImage startAnimatingWithImagesInRange:NSMakeRange(0, 4) duration:0.2 repeatCount:100];
Set the image as [UIImage imageNamed:#"entering"] then call startAnimatingWithImagesInRange:duration:repeatCount:
Check it out here: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceImage_class/#//apple_ref/occ/instm/WKInterfaceImage/startAnimatingWithImagesInRange:duration:repeatCount:
Make sure to follow the tips here: https://developer.apple.com/watchkit/tips/

How to get system images programmatically? (example: disclosure chevron)

I want to create UIImageView with some system-image in it. (Example: the disclosure chevron image, etc.). How can I do so programmatically?
Note: I don't want to download the image and add it to the project, I want to fetch it from the user programmatically / from the Interface Builder.
From iOS 13 and Xcode 11 you can get system images by giving system name.
let image = UIImage(systemName: "info.circle")
Reference : UIImage Apple Documentation
If you mean you can to set the button to use the system disclosure icon, just do as #middaparka suggested and use this:
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
If you're asking how you can access the image directly, you can't do that. This is your only option: Use default apple icons for pdfs and docs in iOS app?
I think iOS-Artwork-Extractor is the tool you are looking for. It lets you extract the artwork into png files.
There is no clean programmatical way to access the images of system buttons. Quote from the documentation of the UIButton.imageView property:
The value of the property is nil for system buttons.
You may do an off screen rendering of the views and extract the resources on the fly but that's a very shaky approach. It's better to extract every asset you need and use them as intended. You'll suffer much more in the end with the programmatic way.

Zbar not working after changing setSymbology

I want Zbar to capture images as well as scan QR code with the single Zbar reader without dismissing it from the current ViewController.
For that I was using
[reader.scanner setSymbology:ZBAR_QRCODE config: ZBAR_CFG_ENABLE to:1];
to enable when the slider changes to the QR code mode and
[reader.scanner setSymbology:ZBAR_QRCODE config: ZBAR_CFG_ENABLE to:0];
to disable the QR code mode when the slider is set to certain value.
It is not working properly by changing like that. If the QR code is enabled initially, the zbar reader scans well the QR code.
But I wanna show just an image picker initially, so I put on the above code that disables the QR code mode and would change the symbology as needed. By changing the symbology, the QR code is not working. Can someone please help me fixing this showing me what went wrong?
Im working on the latest release with iOS 6.0. Thanks in advance.
You would have probably solved the problem by now. The problem is hard to imagine though but one of either solution will solve it:
Use ZBarReaderController instead of the ZBar ReaderViewController so you have control when the barcode gets captured. (The symbology support is set once before you initialise
the controller I do not believe you can change symbology support dynamically, also since you only disabled QR Codes - it will continue to support the other 20 or so barcode formats.
If you want to pick images from the camera roll you need to do it outside the Z bar reader controller but you should still be able to decode the resulting image using Z-Bar - it should be easy to figure out in the sample app.

Resources