IDE: XCode Version 12.4 (12D4e)
- 新建App

- 给项目命名为
HelloWorld,Interface选择Storyboard,Language选择Objective-C。

- 打开文件
Main.storyboard,添加一个Label和Button组件。

- 打开两个面板,一个显示
Main.storyboard,另一个显示ViewController.h

为Label新建
New Referencing Outlet(右键点击Label,点击New Referencing Outlet后的点不松开,拖到ViewController.h中。将新的Referencing Outlet命名为helloLabel。
为Button添加
Touch Up Inside事件,将事件命名为showHelloWorld。
这时,ViewController.h的代码变为:1
2
3
4
5
6
7
8
9
10// ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *helloLabel;
- (IBAction)showHelloWorld:(id)sender;
@end同时,
ViewController.m中也自动添加了- (IBAction)showHelloWorld(id)sender {}函数,在其中添加_helloLabel.text = @"Hello World";
至此,最简单的IOS App开发完成。