User Code List
All my code
---Android
------Sending SMS using Intents
------Send email attachment
------read file from sdcard
------get size of screen
------Accelerometer in Android OS 2.x and deprecated API
------Getting Animation Drawables to actually Animate
------hide the status bar and title bar
------Email, send intent
------wifi scanner
---------New Snippet
------scrollable tabhost
------bluring windows when dialog shows up
------Animated activity transition, diagonal slide
------simple way to scale image
------monitor outgoing phone call
------add directory in sdcard
------EditTextPreference only numbers
------MapView, LongPress, GestureDetector, OnTouchListener
------Preference Screen with custom views
------write and read data from file
------background without stretching
------System setting, change and write_settings
------Creating Persistent AlertDialog for on Orientation Change
------print from Android application
------Screen in landscape mode
------add contact photo to your list
------Distance calculation between 2 Geopoint by Haversine formula
---Iphone
------get iphone orientation
------generate pdf from iphone
------new thread autorelease pool
------determine firmware version
------turn page animation
------load resource file to webview
------call javascript in Objective-C code
------call objective-C code from Javascript
------Disable Webview selection flash
------Disable the action popup
------Disable webview zoom effect
---Utilities
------recursive remove .svn directory
New Snippet
 
 
call objective-C code from Javascript
 

Basically you create a protocol like below:

myapp:myfunction:myparam1:myparam2

And then in Javascript:

document.location = "myapp:" + "myfunction:" + param1 + ":" + param2;

Then back in your Objective-C code:

- (BOOL)webView:(UIWebView *)webView2

shouldStartLoadWithRequest:(NSURLRequest *)request

navigationType:(UIWebViewNavigationType)navigationType {

NSString *requestString = [[request URL] absoluteString];

NSArray *components = [requestString componentsSeparatedByString:@":"];

if ([components count] > 1 &&

[(NSString *)[components objectAtIndex:0] isEqualToString:@"myapp"]) {

if([(NSString *)[components objectAtIndex:1] isEqualToString:@"myfunction"])

{

NSLog([components objectAtIndex:2]); // param1

NSLog([components objectAtIndex:3]); // param2

// Call your method in Objective-C method using the above...

}

return NO;

}

return YES; // Return YES to make sure regular navigation works as expected.

}

 
Sub-Article List