How to put Image in Custom Keyboard? - objective-c

I am a iOS application developer. I am now working with iOS8 custom keyboard.
I have created a custom keyboard with custom view. I can put their button and view.
I am unable to put image or animated image(GIF) over there. Can any one please help me to make this done.

You can't use GIF images in custom keyboard. Add the png images into custom keyboard target directory ( Not your application directory ).
After adding the images, Check in custom keyboard target -> Build Phases -> Copy Bundle Resources. If images not added here, add the images using + button

Related

Objective C: Custom keyboard extensions with images in iOS

I have created custom keyboard in my application.Now i want to display only 8 images at the beginning and later after payment i want to display whole collection of images. I am checking condition for payment if its done then only show all images but i cant debug it why images are not displayed even though condition is satisfied.
Also my question is keyboard view is base class of UIInputViewController so it will hit only once after app execution.
Please any help would be appreciated.
Click on image resources and then File Inspector tab in right side. Check Targets are selected or not.

Add Stickers in Custom KeyBoard Extension

I am looking to create a Custom Keyboard for iPhone,iPad. I have successfully integrated Phrases and Emoticons into the Keyboard, But couldn't get any idea how to add stickers in the keyboard.
Anyone knows how to add ?
Thanks.
I recently created a custom keyboard for sending stickers on iPhone. I noticed this question is tagged as Objective-C but I will be responding in Swift since that’s how I did it.
If I am understanding your question correctly, “add stickers in the keyboard” may refer to stickers similar to those on Facebook Messenger or Peach. My personal inspiration came from wanting to create something similar to Kim Kardashian’s KIMOJI app. This custom keyboard extension works by allowing the user to tap on a sticker, copy it, and then paste it into an input field to send.
To begin with, I found this great custom keyboard tutorial on AppCoda: Creating a Custom Keyboard Using iOS 8 App Extension (written in Swift). The tutorial walks you through how to create a new keyboard extension within an app, add a view which holds buttons (or keys), and apply appropriate constraints. However, I found all the details of creating keys less necessary for a sticker keyboard.
Following the tutorial, once you create a basic keyboard with a KeyboardViewController and KeyboardView xib, I added UIButtons. In my case, I added six buttons to correspond to six stickers. The first UIView row and second UIView row both held three buttons each. I applied constraints so that each button was equal height and width (approximately 100 x 100). In Storyboard, I clicked on each button and in the attributes inspector I set the button “image” property to the corresponding sticker image I had in my assets. Also, to determine an appropriate height for my keyboard, I found this helpful resource: iPhone Development 101 - iPhone & iPad Keyboard Sizes.
Note: In order to create stickers you need images of some sort. I drew / designed my own. You could also design them using Adobe Illustrator or an equivalent program.
Once you set the images for each button and run the app, the images may not appear. To fix this, I had to visit my sticker keyboard Target > Build Phases > Copy Bundle Resources to ensure Assets.xcassets was included. Running the app again, the images appeared.
Next, assuming you have created a KeyboardViewController that corresponds to your KeyboardView.xib, you can create a corresponding #IBAction for each button/sticker in the view controller. We want the user to copy the sticker selected to Pasteboard so they can send the stickers. To enable your custom keyboard to access Pasteboard, go into the keyboard extension’s Info.plist file. Under Information Property List > NSExtension > NSExtensionAttributes, change the RequestsOpenAccess property to YES.
Now, the IBAction method you created can assign the appropriate sticker image path to the Pasteboard! This is very generally how my code looked:
#IBAction func stickerPressed(sender: UIButton) {
let image = UIImage(named: "sticker")
UIPasteboard.generalPasteboard().image = image
}
When you run and test your app on a device and install it, click the globe icon on the keyboard to switch to your custom keyboard. Tap on a button/sticker, then tap in an input field to paste. In Facebook Messenger, options may appear to “Send Photo” “Edit” or “Cancel.” In Peach or Messages, it will send inline. It just depends on the app.
This process worked for me and I hope it can help someone else out there!
You can create UIImageView inside UICollectionView or UITableView, and show sticker images inside these UIImageViews. And when user taps on them, just get the UIImage present in that view.

Apple Watch Images not showing on simulator

I am working with the apple watch and I would like to just simply set an image in the storyboard. It is a png file and I set it in the storyboard, but it doesn't show up in the simulator. I have tried all of the aspect and fitting options. I believe the view is called a wkinterfaceimage. I have also tried adding programmatically and that does not show up either. Hidden is not checked. Any ideas of what I might be missing?
If you have your image included as a file in your app's bundle select the file, choose File Inspector and add the target under Target Membership:

Image load on iOS simulator but not on iPad

The title pretty much describe my problem. I have a UIButton on which I applied a .png background. The .png load fine on the iOS simulator but not on the actual iPad. Any hints as to why it does that ?
EDIT:
When the view with the button in question loads I get this error message in the console
Could not load the "fosse.png" image referenced from a nib in the bundle with identifier "ca.polymtl.PolyPuttZE"
Try doing this.
In Xcode press:
Command+Shift+K and press Yes.
Command+Shift+Alt+K and press Yes.
The try building, running.
Also, check if the image has correct targets (you can check by clicking on the image in Xcode and then in Inspector you'll find build targets).
I've solved the problem. Turns out that the image wasn't encoded as a png even if it had the proper extension. So I juste opened it with gimp and exported it as a PNG.
Click on your project. Then go to the Build Phases tab and ensure that the file is in the Copy Bundle Resources list.
If not then add it...

How to change image displayed on image browser?

I want to build an application that when the folder is drag and drop to my app, it will retain path and show custom image. so here is the screen shot of my app.
So as you can see in the screen shot, when i drag and drop folder on my app it will display the folder with the custom frame. So the problem is i want to change the folder icon shown in my app to other picture. I am still new to cocoa programming so i hope anyone can point what code to use to change the folder icon in my app. anyway i am using xcode 3.2 to build my app.
You need to point to a directory that contains images. if you point to a directory that only contains directories, this is what you get.