Cocoa NSWebView, editable and paste
I recently had a problem with an editable webview in my application. The paste or cmd-v was correctly working for a text/plain or text/html clipboardData, but copying an URL from the browser top bar, and pasting it in the webview was not working at all (nothing at all is appearing). Here is how I did: 1. set your webView editable: [myWebView setEditable:YES]; 2. load your html in the webView: [[myWebView mainFrame] loadHTMLString:yourhtml baseURL:nil]; (yourhtml is your html code …) 3. set the onpaste handler: when the html is really loaded, use this delegate: -(void)webView:(WebView...
read moreHow to make Notifier Pro for Gmail your default mail app
Since Yosemite, Apple is not allowing the sandboxed application to change the default application handler, so we can’t make it within the application itself. But the good news is that Notifier Pro for Gmail is able to answer to the mailto: URLs, and here is how you can proceed to make the change: 1. Open the Mail.app (the one installed by default on your system). 2. On the top menu, Mail -> preferences 3. in the General tab, the first option: Default email reader . Change this to ‘Notifier Pro for Gmail’, located in your Application’s folder. that’s it, now...
read morePlay with shaders – black and white – part 1
While developing my game ‘Ice Heroes’, i discovered the shaders with cocos2d. I won’t explain in detail what is it, there is tons of resources about it, but basically, it is a small program used to display an object (http://www.opengl.org/wiki/Shader). If you have a look at the cocos2d sources, you can see that every node rendered on screen is using a default shader: kCCShader_PositionTextureColor. This program key is set in CCShaderCache.m in loadDefaultShaders. It is composed of a vertex shader (executed on every vertex), and a fragment shader (executed every pixel on...
read moreTwitter post with cocos2d 2.x
Here is what i am using for tweets: You need the twitter.framework and #import <Twitter/Twitter.h> -(void) postTweet { AppController * app = (((AppController*) [UIApplication sharedApplication].delegate)); TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init]; [tweetViewController setInitialText:@"blablabalbalblabla"]; [tweetViewController setCompletionHandler: ^(TWTweetComposeViewControllerResult result) { dispatch_async(dispatch_get_main_queue(), ^{ { if (result == TWTweetComposeViewControllerResultDone) { //success } else if(result ==...
read moreInstagram and cocos2d 2.x
A quick method to send a photo to instagram -(void)postInstagram { AppController *app = (AppController*) [[UIApplication sharedApplication] delegate]; UIImage * screenshot = [self takeScreenShot]; NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Screenshot.igo"]; // Write image to jpeg [UIImageJPEGRepresentation(screenshot, 1.0) writeToFile:savePath atomically:YES]; NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { UIDocumentInteractionController *documentInteractionController =...
read morePosting on facebook with cocos2d
This is another quick tutorial, showing how to post / email what you need. We will use the social.framework (don’t forget to add it to your library list, or you won’t be able to use the SLComposeViewController. I was using ShareKit (i should say trying to use) for all my needs (facebook, emails, tweeter, instagram etc….), the install setup is imho too heavy and time consuming. I also had several strange bugs like window not appearing every time (first button tap: no window, second: FB window appeared, then never appear….). Posting is usually some lines of code, i...
read more
Recent Comments