Share extension custom UI. Button has not got image - ios

I am using share extension with custom UI, So I configured my view controllers in storyboards, and add image (and tried add background image) to the button. So in storyboard I see that image. But when I run extension I don't see image on the button.

So the issue is because seems I don't add my images to the new target. So if you create a new target, and extension it's our new target we should be sure that all needed resources like images, strings are added to it.
So just use target membership to checkmark needed files or add it via xcode project "Build Phases" tab.
So it's also connected to other classes you want to use. Sometimes can be a pain to add all of them because some classes import other classes and etc.

Related

Share image resources between app and today widget

Can I share resources (images that are compiled into the application) between my main iOS app and my today extension widget? Say I create a new application. Then add a today extension project to the solution. And then I create a UIImageView. I want to reference an image from a shared pool of images rather than having 2 of every image, one added to main app and another added to widget app.
imageView.Image = UIImage.FromBundle("IMG_3799.JPG");
The IMG_3799.JPG is inside the main application in the References folder of that project. I'd prefer the same image asset to be referenced by the widget. Is that possible? Currently, i'm making a 2nd copy of IMG_3799.JPG and putting it into the widget.
Out of box, you can't.
The closest thing to that would be to create an app group that contains the main app and the extension and that has access to the common folder. However you can't place any file there during deployment, just during runtime, so it may or may not be a workaround for what you require, but that is the only way.
I'm afraid this might be late. Following is what I did with Xcode 12.4
First, go into your Assets.xcassets file in Xcode then select the image you want to be shared.
Second, click "Hide or show the Inspectors" in the top right corner of Xcode.
Thir, click "Show the file inspector"
Then you should see Target Membership where you can simply click the checkbox to have the images to be used in main app, extensions, etc.
I found this method for Wigetkit from 17:10 of this youtube video: https://www.youtube.com/watch?v=ZzBBDrFNXmk
I came across this answer while looking for a way to share images between my main app and my iMessage extension. As it turns out, just by adding the image files to both targets I was able to use one single copy of my images in both places.
In the project navigator, I added the images to a folder (not .xcassets) under my main project (not the extension) and just ensured that the Target Membership was set to both the main app and extension.

Customize storyboards bundled inside iOS Framework file

I have a framework which has storyboard and xib files.
How do I make the storyboards within the framework customizable? i.e. people using my framework should be able to modify the storyboards to customize the look & feel.
When I imported my framework in another app project in XCode, I did not see the storyboard files within my framework. How to make them visible & editable?
Is it even advisable to use framework in this case or should I go with static library+resource bundles combination?
I finally did this,
Load custom xibs,storyboards dynamically. i.e. first try loading custom storyboards, if not present load default storyboard(use try catch to check).
Expose all viewcontroller outlets and event handling functions through header files.
Make connections between buttons in your custom framework and these header file outlets,event handlers. Done! Your Viewcontroller.m functions will be called on clicking on those buttons.

How to rename storyboard and have links from other storyboards preserved

I have two storyboards in Xcode project.
First named Main and second Settings. Main storyboard has storyboard reference to Settings.
I want to rename Settings storyboard to AppSettings. But when I rename it through Xcode Project Navigator, Main storyboard reference to Settings is not automatically updated and project fails to compile.
Of course, I can manually update broken reference, but I wonder is there another way of renaming storyboard in Xcode that would automatically update existing storyboard references?
Yes, Xcode's Find navigator can perform a find & replace operation that includes references inside storyboards. Search for "Settings" and replace it with "AppSettings". Then click "Preview" so you can choose only the relevant instances of "Settings" to replace (I'm assuming that word will appear in unrelated places, since it's rather common.) Afterwards, you will still have to rename the file itself as usual.

Where should I put background and button image files? Assets or just drag into the app files?

I am making an app but I'm not quite sure where should I put the image files? Just drag and copy inside the app or in assests? What's the difference, I'm not quite sure.
I'd strongly recommend using the xcassets, which you can do by dragging your files onto it when you have it open in Xcode. Xcode handles the rest, copying them into your project. Doing this also allows you do call UIImage(imageNamed:), using the title you give to each Image Set. You also don't have to worry about specific naming of the different size classes, as you drag them to the appropriate section there.

Interface builder not showing images to select for UIImageView

I have a couple of images in my Resources directory of my iphone project. I want to set one of those images for an UIImageView.
After adding the images to XCode project and correctly setting their targets to the project, Interface builder is not showing the images to select it in Attributes property of UIImage view. Do I have to refresh the Inspector? Am I missing some step?
If you are using Xcode 3 then I think you have to save all changes and then close Interface Builder and re-open it in order for it to see those changes. Also I would highly recommend moving to Xcode 4 if you are not already using it.

Resources