Giter Club home page Giter Club logo

syemojipopover's Introduction

SYEmojiPopover

Popover view to select emoji character from iOS 6+ possible characters. iOS 6+, ARC.

After cloning the project please run:

// download Popover submodule(s)
git submodule init
git submodule update

It consists in two classes:

  • SYEmojiPopover

  • SYEmojiCharacters

SYEmojiCharacters generates a list of Emoji characters separated in sections, depending on the iOS version the phone is running. I used iOS Emji keyboard to list those characters in the file Characters/characters.txt. It contains Emoji characters shown by iOS keyboard starting from 5.0, and characters supported by the OS even if they are not in this keyboard.

It contains the following methods:

// singleton for this class
+(SYEmojiCharacters*)sharedCharacters; 

// determines if a string is an Emoji character supported in this iOS version
-(BOOL)isCharacterEmoji:(NSString *)string; 

// number of sections of characters
-(NSUInteger)numberOfSections; 
// number of characters in the section
-(NSUInteger)numberOfRowsInSection:(NSUInteger)section; 
// character in given section at given index
-(NSString*)emojiAtRow:(NSUInteger)row andSection:(NSUInteger)section;

The second class, SYEmojiPopover, is the popover view. The popover in itslef is made by NicolasChengDev and can be found here: WYPopoverController. The view in the popover is implemented with UITableView. It is much quicker than GMGridView that you may find in previous versions, but the ability to change the size of the control is a little bit harder, explaining why it hasn't been implemented yet.

Here are the methods you can use:

// delegate
@property (weak, atomic) id<SYEmojiPopoverDelegate> delegate;

// show the control at the specified point of a view, using a title
-(void)showFromPoint:(CGPoint)point inView:(UIView*)view withTitle:(NSString*)title;

The delegate property implements SYEmojiPopoverDelegate, consisting in those methods:

// required, will be called when a character is tapped
-(void)emojiPopover:(SYEmojiPopover*)emojiPopover didClickedOnCharacter:(NSString*)character;

Sample project

Popover Emoji character selected

A sample project is included along with the sources. It consists in a simple project showing the popover and displaying character after a click.

The instance to the popover is a private member of the main view controller:

@interface SYViewController : UIViewController <SYEmojiPopoverDelegate> {
@private
	SYEmojiPopover *_emojiPopover;
}

When clicking on the button:

- (IBAction)selectEmojiClick:(id)sender {
	if(!self->_emojiPopover)
    	self->_emojiPopover = [[SYEmojiPopover alloc] init];

    [self->_emojiPopover setDelegate:self];
	[self->_emojiPopover showFromPoint:self.buttonEmoji.center 
	                            inView:self.view
	                         withTitle:@"Click on a character to see it in big"];
}

Method called when clicking on Emoji character:

-(void)emojiPopover:(SYEmojiPopover *)emojiPopover didClickedOnCharacter:(NSString *)character
{
	[self.labelEmoji setFont:[UIFont fontWithName:@"AppleColorEmoji" size:100.f]];
    [self.labelEmoji setText:character];
}

Characters app

The repo also contains a simple OSX app. Its goal is to create the -(void)loadCharacters method of SYEmojiCharacters using a text file - mine is the Characters/characters.txt file.

The text file uses a home made structure, respect it carefully in order to get the app working.

I included it to have it along with this project on the same repo, but it will only be useful for those of you who want to add characters or organize sections differently.

Contributing

Any contribution of any sort is warmly welcomed, so if you have any question, suggestion or bug report please do not hesitate to contact me on Github, it will be more than a pleasure to answer you.

If you app is using this code please contact me so I can add it to a list of app for people to see this project.

License

I do not really know licenses, so I won't give one precisely. I will just specify some rules I think fair:

  • this code is free to use for both free and commercial use.
  • you can modify it, fork it and redistribute it as you wish as long as I am somewhere in the thanks or licenses of the final program and the new code.

I hope you'll enjoy it,

-- dvkch

syemojipopover's People

Contributors

dvkch avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.