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

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 墨墨

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,运行,搞定!