歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> iOS版的Hello world

iOS版的Hello world

日期:2017/3/1 10:21:05   编辑:Linux編程

最近下載了個xcode_4.3.1_for_lion.dmg ,安裝 xcode 時老是提示安裝失敗,後來網上查了下,把mac日期修改成2012.1.1,才能安裝成功。第一次寫ios程序啊,程序相當簡單,就一個helloworld 點擊按鈕觸發alert事件

開發環境 mac 10.7.3 xocde4.3.1 ios5.1.x

開發步驟

1. 下載安裝 xcode_4.3.1_for_lion.dmg

2.運行xcode

3.新建一個Single View Application

4.創建完成後雙擊文件中的MainStoryboard_iPad.storyboard文件打開設計界面

5.拖個Round Rect Button控件到界面裡面

6.修改ViewController.h頭文件 加入代碼

@interface ViewController : UIViewController

{

IBOutlet UIButton * btn;

}

-(IBAction)btnPressed:(id)sender;

7.修改ViewController.m文件 加入代碼

-(void)btnPressed:(id)sender

{

NSLog(@"33333333");

UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"hello"

message:@"zhu"

delegate:self

cancelButtonTitle:@"ok"

otherButtonTitles:nil];

[alert show];

}

8.右鍵單擊View中添加的按鈕分別添加Touch Up Inside 跟 btnPressed, Referencing Outlets跟btn的 關聯

9.虛擬機運行效果

10.真機調試時如果有如下提示,需要進行xcode破解

12. 在的越獄的板子上運行效果

Copyright © Linux教程網 All Rights Reserved