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.
Related
I am looking for a way to add several toolbar buttons to Finder, which, when clicked, perform certain actions.
My research shows that injecting code into Finder process is impossible on latest versions of macOS due to SIP, yet this would be the most seamless way for the user.
There is a possibility to add a toolbar item by creating a Finder Sync extension. However there are 2 problems:
There can be only one toolbar button per extension (I need several buttons)
The toolbar button will have a dropdown arrow (see an image below). I do not need to show a menu, however, and therefore this arrow makes the button misleading. It must be a simple plain button that matches the current system theme and performs an action upon click.
So this is what I don't need (because of the drop down arrow):
Update:
One of the ways to add a button, is drag and drop an .app bundle, holding Command key.
This approach has the following problems:
This button wouldn't match the other toolbar buttons look&feel, as the icon for such button is taken from the .app bundle (so it wouldn't switch based on macOS light/dark theme, for example)
It is impossible to add several toolbar buttons like that (as there needs to be one .app per 1 button). However, I need multiple buttons.
I am wondering if FinderSync allows creating "normal" (non menu) buttons
Is there a way to add a regular button to Finder's toolbar?
Please check out my Finder buttons:
https://github.com/lexrus/LTFinderButtons
Basically, I made every task a button app.
I'm trying Finder Sync Extension to do the same thing. All issues you found are true. Furthermore, there's problem #3:
You can not submit an app with Finder Sync Extension to the App Store.
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.
I'm trying to simulate a press of this media buttons by code in a macbook:
The idea is to pause, rewind... the music with the uibuttons in my app. It's posible to do this? I did't find anything.
Something like this:
- (IBAction)playButtonClick:(id)sender {
//code here to play music, like if we pressed the physical play media key
}
I would draw images for that (probalby in two resolutions, one for retina and one for non-retina, while in most cases a retina version is sufficient) in two variations, one in regular mode and one as if the button is currently pressed.
Then use a simple UIButton object for each of them.
And right, when you create the buttons programmatically, then you can use
- (void)playButtonClick:(id)sender
as target for the play button. However, when you want to create and locate the buttons in Interface Builder or Storyboard Editor respectively, then it should be
- (IBAction)playButtonClick:(id)sender
which enables the IB to allow you to draw the connection to the action within IB accordingly.
I am currently trying to add multiple imageviews like in this picture (http://i.imgur.com/DEkoBD0.png) to a view controller. I would also like the option to be able to delete specific images, and also have the whole view controller in a scrollview incase the user wants to add numerous images.
So far I have one imageview that can be set to either a picture from the camera or from the photo library, what I would like is when a user add's a image, another option displays next to it to upload another image such as the picture in the link I provided.
I am currently using the Xcode 5 with storyboards and developing for iOS 7 also.
Any help is appreciated.
Thanks.
Simply use a UICollectionView !
Reference : https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html
It will allow you to add functionalities like delete or add for example (w/ ScrollView ;) )!
I'm writing an app based around a calculator-like UI. On an iPad, I'd like the number UIButtons on my calculator UI to respond to the numbers on the external keyboard. I have no text input anywhere in the app, and I'd never want an on-screen keyboard to appear. How do I get my UIButtons to respond to specific key presses as if they'd been touched?
I'd say create a hidden UITextField with the delegate set, make it become the first responder upon viewDidLoad. The keyboard won't appear when a bluetooth keyboard is connected as far as I know, then just check what characters are typed in the shouldChangecharactersInRange and activate the right buttons accordingly.
EDIT: a quick example I just made, https://github.com/benjaminq42/buttonTest , if you wish to have a highlight animation of some sorts you need to create a custom UIButton class. You can use 'setHighlighted' but that 'sticks'.