Nativescript Mediafilepicker customizing DKImagePickerController UI - ios

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

Related

how to replace Image in Lottie animation at runtime in 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()

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.

Can I use the default UIBarButton icons provided by Apple in other assets of my app?

Like in UIButton or a UIImageView etc..
If so how do I do that using the StoryBoard or in a Xib
I am able to use the default icons inside UIBarButton items but cannot look them up in normal buttons . A solution using Storyboard would be really nice
In order to use them you need to extract them using a handy little app called (fittingly enough) iOS Artwork Extractor. I use it all the time when I want to mimic iOS system behaviours.
Download the Xcode project at:
https://github.com/0xced/iOS-Artwork-Extractor
Or another way:
The Other.artwork file is in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/ (you need the SDK).
Use the "iPhoneShop-1.3.jar" program -- available currently here to extract all of the images into a directory.
java -jar iPhoneShop-1.3.jar ARTWORK Other.artwork EXPORT Other
No you cannot use UIBarButtonItem on other as subview like UIButton. UIBarButtonItem can only over UINavigationBar.

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.

How to include skins in ios app

I developed a new iPad calculator and am working on an update for it that has a settings option where you can change the app's skin. Currently, I am using different UIViewControllers for that, but it is not the best solution.
To build on #MJN's answer, once you have selected a skin/theme class, you can easily apply it across your app using UIAppearance, which lets you set styles for all instances of common UIKit classes like UIButton, UIBarButtonItem, UINavigationBar, etc.
You can make an AppSkinProtocol that has methods like the following
- (NSString*)skinIdentifier;
- (UIColor*)highlightedButtonColor;
- (UIImage*)successfulDownloadAlertBackground;
Then make subclasses of NSObject that conform to your AppSkinProtocol.
You can then make a AppSkinManager to save the selected skin to NSUserDefaults. When the app launches load the skin with the identifier matching the string saved to defaults.

Resources