Openurl usage:
View plaincopy
To clipboardprint?
- [[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: appstring];
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: appstring];
The system appstring includes:
View plaincopy
To clipboardprint?
- Map http://maps.google.com/maps? Q = Shanghai
- Email mailto: // myname@google.com
- Tel: // 10086
- Msg sms: // 10086
Map http://maps.google.com/maps? Q = Shanghai
Email mailto: // myname@google.com
Tel: // 10086
Msg sms: // 10086
In addition, you can customize the URL as follows:
View plaincopy
To clipboardprint?
- Open info. plist and add a URL types
- Expand URL types, expand Item1, and change the URL identifier in Item1 to URL scheme.
- Expand the URL scheme and change the content of Item1 to MyApp.
- Other programs can access this custom URL through MyApp: //
Open info. plist, add a URL types extension URL types, expand Item1, and change the URL identifier under Item1 to URL scheme extension URL scheme, modify the content of Item1 to MyApp. Other programs can access this custom URL through MyApp: //
References:
P. P1 {margin: 0.0px 0.0px 0.0px 0.0px; Font: 14.0px Menlo}
Http://iphonedevelopertips.com/cocoa/launching-other-apps-within-an-iphone-application.html
Openurl can help you run maps, SMS, browser, phone, and other applications. This is a piece of code that I often need during iPhone development. It only has one line.
View plaincopy
To clipboardprint?
- -(Ibaction) openmaps {
- // Open the map
- Nsstring * addresstext = @" Beijing "; // @" 1 infinite loop, Cupertino, CA 95014 ";
- Addresstext = [addresstext stringbyaddingpercentescapesusingencoding: nsasciistringencoding];
- Nsstring * urltext = [nsstring stringwithformat: @ "http://maps.google.com/maps? Q = % @ ", addresstext];
- Nslog (@ "urltext ========================%@", urltext );
- [[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: urltext];
- }
-(Ibaction) openmaps {
// Open the map
Nsstring * addresstext = @ "Beijing ";
// @ "1 infinite loop, Cupertino, CA 95014 ";
Addresstext = [addresstext stringbyaddingpercentescapesusingencoding: nsasciistringencoding];
Nsstring * urltext = [nsstring stringwithformat: @ "http://maps.google.com/maps? Q = % @ ", addresstext];
Nslog (@ "urltext ========================%@", urltext );
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: urltext];
}
View plaincopy
To clipboardprint?
- -(Ibaction) openemail {
- // Open mail
- // Fire off an email to Apple support
- [[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "mailto: // devprograms@apple.com"];
- }
-(Ibaction) openemail {
// Open mail // fire off an email to Apple support
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "mailto: // devprograms@apple.com"];
} View
Plaincopy to clipboardprint?
- -(Ibaction) openphone {
- // Call
- // Call the Google 411
- [[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "Tel: // 8004664411"];
- }
-(Ibaction) openphone {
// Call
// Call the Google 411
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "Tel: // 8004664411"];
} View
Plaincopy to clipboardprint?
- -(Ibaction) opensms {
- // Open the text message
- // Text to Google SMS
- [[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "SMS: // 466453"];
- }
-(Ibaction) opensms {
// Open the text message
// Text to Google SMS
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "SMS: // 466453"];
}
View plaincopy
To clipboardprint?
- -(Ibaction) openbrowser {
- // Open the browser
- // Lanuch any iPhone developers fav site
- [[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "http://itunesconnect.apple.com"];
- }
-(Ibaction) openbrowser {
// Open the browser
// Lanuch any iPhone developers fav site
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "http://itunesconnect.apple.com"];
}