How to use OpenURL:
View Plaincopy Toclipboardprint?
[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:appstring]];
Among the system's appstring are:
1.Map Http://maps.google.com/maps?q=Shanghai
2.Email Mailto://[email protected]
3.Tel tel://10086
4.MSG sms://10086
OpenURL can help you run Maps,sms,browser,phone and even other applications. This is a piece of code that I often need to use in iphone development, and it's just a single line.
-(ibaction) Openmaps {
Open map
Nsstring*addresstext = @ "Beijing";
@ "1Infinite Loop, Cupertino, CA 95014";
Addresstext =[addresstextstringbyaddingpercentescapesusingencoding:nsasciistringencoding];
Nsstring*urltext = [nsstringstringwithformat:@ "http://maps.google.com/maps?q=%@", Addresstext];
NSLog (@ "urltext===============%@", urltext);
[[Uiapplicationsharedapplication] Openurl:[nsurl Urlwithstring:urltext];
}
-(ibaction) Openemail {
Open mail/Fire off a email to Apple support
[[UIApplication sharedapplication]openurl:[nsurl urlwithstring:@ "Mailto://[email protected]"];
}
-(ibaction) Openphone {
Dial number
Callgoogle 411
[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "tel://8004664411"];
}
-(ibaction) opensms {
Open sms
Text Togoogle SMS
[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "sms://466453"];
}
-(ibaction) Openbrowser {
Open your browser
Lanuch any IPhone developers fav site
[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "http://itunesconnect.apple.com"];
}
Call Google Maps inside iphone program
Use the Cllocationmanager class, Mkmapview. and achieve <MKMapViewDelegate,CLLocationManagerDelegate>
Initialize Cllocationmanager,cllocationmanager to get current geographic coordinates
Locmanager=[[cllocationmanager Alloc]init];
[Locmanager setdelegate:self];
Set accuracy
[Locmanager Setdesiredaccuracy:kcllocationaccuracybest];
[Locmanager startupdatinglocation];
After execution, the proxy method is automatically invoked:
[Go] How to use iOS learning--openurl