[Go] How to use iOS learning--openurl

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.