Second, open the map "Apple iOS example Programming Primer Tutorial"

Source: Internet
Author: User
Tags button attributes uikit

The app is the app's function to open the Google Maps active address connection to your iphone

Current version of SDK 8.4 Xcode

Run Xcode Select Create a new Xcode project->single View application named OpenURL

(1) Open ViewController.h file in Xcode

(Red is the added code)

#import <UIKit/UIKit.h>

@interface Viewcontroller: uiviewcontroller

-(ibaction) Openmaps: (ID) sender;

@end

(2) Open viewcontroller.m file in Xcode

#import "ViewController.h"

@interface viewcontroller ()

@end

@implementation Viewcontroller

-(void) viewdidload {

[Super viewdidload];

additional setup after loading the view, typically from a nib.

}

-(void) didreceivememorywarning {

[Super didreceivememorywarning];

//Dispose of any resources, can be recreated.

}

-(ibaction) Openmaps: (ID) Sender {

nsstring *addresstext = @ "1 Queen St, Auckland, NZ";

Addresstext = [Addresstext stringbyaddingpercentescapesusingencoding: Nsasciistringencoding];

nsstring *urltext = [nsstring stringwithformat:@ "http://www.google.cn/maps/place/%@" , Addresstext];

[[uiapplication sharedapplication]openURL: [nsurl urlwithstring : Urltext]];

/*

How to use OpenURL:

Among the system's appstring are:

Map Http://maps.google.com/maps?q=Shanghai

Email Mailto://[email protected]

Tel://10086msg

sms://10086

In addition to this, you can also define your own URL by:

Open info.plist, add a URL types expand the URL types, expand Item1, change the URL Item1 under identifier to URL scheme, expand URL Scheme, modify the contents of Item1 to MyApp Other programs can access this custom URL through myapp://

OpenURL can help you run Maps,sms,browser,phone and even other applications (custom URLs to the application being launched)

*/

}

@end

(3) UIView interface settings
-Black background

Click Main.storyboard

Select View Controller->view

Set the background to black

Select Attributes Inspector->background->black Color

(4) Add Button, click to open the connection

Select: Tools--Library; Drag a Button from the Library display menu to Main View


Click on the button on the main display, and enter "Open Google Map" from the title inside the button Attributes.

(5) write to the UIButton class file

Right-click the button control and move the mouse over the circle behind "Touch up Inside"; The circle becomes (+); Drag to a straight line to connect to the "view Controller";
Release the mouse Select button appears "Openmaps:"; Pick it up.

Select: File--Save


Finally, in XCode, choose Build and then Running

(6) Simulator commissioning

This article originated from the online blog tutorial, after I modified and tested. Original Blog Address http://blog.sina.com.cn/s/blog_5fae23350100dmln.html

Second, open the map "Apple iOS example Programming Primer Tutorial"

Related Article

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.