惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 墨墨

Windows Phone 7中配置gmail, 使用outlook 同步邮件,日历,联系人等 iPhone 闭包应用 iPhone屏幕旋转的例子 objective-c的TextFields输入完成后关闭键盘和触摸背景关闭键盘 第一个objective-c程序 iPhone自动化测试 visual studio 2010 ultimate 下载 suse下设置IP的两种方法 freebsd下之简单安装python ibatis.net私人学习资料,勿下(加密) ibatisnet高级查询 Python相关中文学习资料 搭建python的web开发环境 windows下 使用Aptana搭建Python开发环境 使用SharpZipLib 解压zip 2012年真的是世界末日吗?_全球关注 关于生成静态页--终极解决方案 Json格式类的转换相关代码 Extjs 登录界面源码
第一个iPhone程序之Hello World
墨墨 · 2010-10-18 · via 博客园 - 墨墨

新建一个iPhone的Window BaseView工程

然后在Class中新建文件UIViewControllerSubclass文件,我们使用Hello文件名,勾选下面的With XIB for user Interface,选择next

OK,文件新建成功,在文件列表中出现Hello.h,Hello.m,Hello.xib,可以把xib移动到Resource文件夹中,这样规范一点

然后我们打开Hello.h

我们自定义一个方法为SayHello,方法体如下:

- (IBAction) SayHello;

然后选择相对应的Hello.m文件,也可以按快捷键Command+Ctrl+向上的光标键

我们来实现这个方法,代码如下

- (IBAction)SayHello

{

UIAlertView *view=[ [UIAlertView alloc]initWithTitle:@"提示" message:@"You Got it." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; //初始化UIAlertView,并写入相关参数,学过C#的可以理解为MessageBox msgBox=new MessageBox(Title,Content....)

[view show];    //这边就是把刚才的view显示出来 msgBox.show();

[view release]; //这个是释放资源

} 

OK,SayHello方法完成

然后我们打开系统的degelate.h文件,来声明我们刚才写的类

首先需要import "Hello.h"   //这个很类似java的写法

然后我们在接口初始化方法里初始化我们刚才写的类

Hello *hello ;

在方法外来引用

@property (nonatomic,retain) Hello *hello;

完整代码如下:

//

//  RepeatHelloAppDelegate.h

//  RepeatHello

//

//  Created by Scott on 10-10-18.

//  Copyright 2010 __MyCompanyName__. All rights reserved.

//

#import <UIKit/UIKit.h>

#import "Hello.h"

@interface RepeatHelloAppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;

Hello *hello;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic,retain) Hello *hello;

@end

下面我们来搞定相对应的.m实现文件

打开文件我们首先看到@synthesize这样的关键字,还有上面的@property,我们参见http://www.360doc.com/content/10/0329/09/1014216_20687179.shtml

我们先@synthesize hello;紧接着在didFinishLaunchingWithOptions方法里写初始化

hello=[[Hello alloc]init]; addSubview];

[window:hello.view];

OK,整个编码部分已经完成,下面就开始拖拉了

 打开Hello.xib,然后在界面上拖上一个RoundRectButton

右击Button,选择touch inside事件,连线到File's Owner,选择SayHello方法,OK,运行,搞定!