Ios learning Summary (1), ios learning Summary

Source: Internet
Author: User

Ios learning Summary (1), ios learning Summary

Original article address

Download and open xcode.

Create a new project, as shown in:

Click Create a new Xcode project, select Application under ios, and click Single View Application to Create our first project. :

After creating a project, we will compile our first ios project.

Find the AppDelegate. m file and add it under "# import" AppDelegate. h:

#import "ViewController.h"

Then add the following code to the didfinishlaunchingwitexceptions function:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];self.window.rootViewController = [[ViewController alloc]init];[self.window makeKeyAndVisible];


The overall structure is shown in:

Next, open ViewController. m and add the following in the viewDidLoad function:

UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];[btn setBackgroundColor:[UIColor redColor]];[btn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn];UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 20)];label.text = @"hello world";[self.view addSubview:label];

Then add the function:

- (void)clickAction{    NSLog(@"Clicked!");}

Shows the overall effect:


Click the run icon, as shown in:

The effect after running is as follows:

When you click the red button, Xcode prints the following information:

So far, our first app has been completed.

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.