欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    实例iPhone SDK 编程入门教程.doc

    • 资源ID:70344767       资源大小:2.46MB        全文页数:86页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    实例iPhone SDK 编程入门教程.doc

    实例 iPhone SDK 编程入门教程 - 第一天DAY ONE - MinutesToMidnight大家一起来建立我们的第一个 iPhone app,给你的iPhone计算离午夜12:00点的剩余时间。首先运行以安装好的 xCode选择: File->New Project.从 "New Project" 窗口  选择 : iPhone OS ->Applications-> View-Based Application命名 : 我这里命名为 "MinutesToMidnight"(1) UIView 界面设置- 黑色背景,红色字体,让它看起来像一个闹钟。双击文件: "MinutesToMidnightViewController.xib" ;然后 "Interface Builder"  会自动打开,在这里我们可以编辑改变界面 选择: Tools -> Reveal In Document Window -> View选择:  Tools -> Attributes Inspector在色条内选择 "黑色",可以看到背景变为黑色(2) 加入 UILabel 显示我们的倒数时间选择: Tools -> Library ; 从Library显示菜单中拖拉一个 Label 到 Main View在主显示上点击 Label;从Label Attributes 上选着字体的颜色和字体大小。(3) 把界面文件更新到我们的代码文件上面在MinutesToMidnightViewController.xib文件窗口, 选择: File's Owner (这步很关键,我在第一次编辑时没成功就因为忘了这一步)选择: Tools->Idenity Inspector在 Idenity inspector 中间 "Class Outlets" 按 "+";把 myOutlet1 改为 "countdownLabel";把 id 改为 "UILabel"; 按回车,确定已更改。(4) 写入"MinutesToMidnightViewController.h" 和 "MinutesToMidnightViewController.m"确认还在MinutesToMidnightViewController.xib文件窗口, 选择: File's Owner选择: File->Write Class Files在 Save As: "MinutesToMidnightViewController"点击: Save点击: Merge在右下角 "Actions" 按下选 (bottom right) "Select Left"点击: 上方红色小圈关闭窗口点击: Save关闭所有 merge 窗口打开 xCode; 选择 Build->Build(5)从 Interface Builder 写入 UILabel 的 class file再打开SDK工具 Interface Builder在主视窗口或文件窗口;点击 Label选择: Tools -> Connection Inspector移动鼠标在"New Referencing Outlet" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner"放开鼠标选择键出现 "countdownLabel" 选上它。选择: File -> Save then close Interface Builde 以上几步,已成功完成界面了,下面我们继续把程式添加我们的代码文件。(6)  在xCode打开 MinutesToMidnightAppDelegate.h 文件没修改前#import <UIKit/UIKit.h>class MinutesToMidnightViewController;interface MinutesToMidnightAppDelegate : NSObject <UIApplicationDelegate>     UIWindow *window;    MinutesToMidnightViewController *viewController;property (nonatomic, retain) IBOutlet UIWindow *window;property (nonatomic, retain) IBOutlet MinutesToMidnightViewController *viewController;end没修改前修改后#import <UIKit/UIKit.h>class MinutesToMidnightViewController;interface MinutesToMidnightAppDelegate : NSObject <UIApplicationDelegate>     IBOutlet UIWindow *window;    IBOutlet MinutesToMidnightController *viewController;    NSTimer *timer;-(void)onTimer;property (nonatomic, retain) IBOutlet UIWindow *window;property (nonatomic, retain) IBOutlet MinutesToMidnightViewController *viewController;end(7)  在xCode打开 MinutesToMidnightAppDelegate.m 文件没修改前#import "MinutesToMidnightAppDelegate.h"#import "MinutesToMidnightViewController.h"implementation MinutesToMidnightAppDelegatesynthesize window;synthesize viewController;- (void)applicationDidFinishLaunching:(UIApplication *)application           / Override point for customization after app launch       window addSubview:viewController.view;    window makeKeyAndVisible;- (void)dealloc     viewController release;    window release;    super dealloc;end没修改前修改后#import "MinutesToMidnightAppDelegate.h"#import "MinutesToMidnightViewController.h"implementation MinutesToMidnightAppDelegatesynthesize window;synthesize viewController;- (void)applicationDidFinishLaunching:(UIApplication *)application        timer = NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:selector(onTimer) userInfo:nil repeats:YES; 不换行      / Override point for customization after app launch       window addSubview:viewController.view;    window makeKeyAndVisible;- (void)onTimer     viewController updateLabel;- (void)applicationWillTerminate:(UIApplication *)application     timer invalidate;- (void)dealloc     timer release;    viewController release;    window release;    super dealloc;end修改后(8)  在xCode打开 MinutesToMidnightViewController.m 文件修改前#import "MinutesToMidnightViewController.h"implementation MinutesToMidnightViewController- (void)didReceiveMemoryWarning     super didReceiveMemoryWarning;- (void)dealloc     super dealloc;end修改前修改后#import "MinutesToMidnightViewController.h"implementation MinutesToMidnightViewController- (void)viewDidLoad     countdownLabel setFont:UIFont fontWithName:"DBLCDTempBlack" size:128.0;    countdownLabel.text = "I0A0IN6"    super viewDidLoad;- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation     return (interfaceOrientation = UIInterfaceOrientationPortrait);- (void)didReceiveMemoryWarning     super didReceiveMemoryWarning; / Releases the view if it doesn't have a superview    / Release anything that's not essential, such as cached data- (void)dealloc     super dealloc;-(void)updateLabel     NSDate* now = NSDate date;    int hour = 23 - now dateWithCalendarFormat:nil timeZone:nil hourOfDay;    int min = 59 - now dateWithCalendarFormat:nil timeZone:nil minuteOfHour;    int sec = 59 - now dateWithCalendarFormat:nil timeZone:nil secondOfMinute;    countdownLabel.text = NSString stringWithFormat:"%02d:%02d:%02d", hour, min,sec; end修改后最后在 xCode 选择 Build->Build and Go下载今天程序文件: MinsToMidnight.zip 实例 iPhone SDK 编程入门教程,来源于下面文章本人根据appsamuck这个网站加以翻译,修改及测试,希望大家多多交流。一切版权归 所有。实例 iPhone SDK 编程入门教程 - 第二天Day Two Bonfire今天试试运用 UIImageView 来制作一个"营火动画"首先运行以安装好的 xCode,和第一天一样选择: File->New Project.从 "New Project" 窗口  选择: iPhone OS ->Applications-> View-Based Application命名: 我这里命名为"Bonfire"(1)在xcode打开BonfireViewController.m 文件在-(void)viewDidLoad  里面添加代码,如下-(void)viewDidLoad/ create the view that will execute our animationUIImageView* campFireView = UIImageView alloc initWithFrame:self.view.frame;          / load all the frames of our animation     campFireView.animationImages = NSArray arrayWithObjects:                                    UIImage imageNamed:"campFire01.gif",                                 UIImage imageNamed:"campFire02.gif",                                 UIImage imageNamed:"campFire03.gif",                                 UIImage imageNamed:"campFire04.gif",                                 UIImage imageNamed:"campFire05.gif",                                 UIImage imageNamed:"campFire06.gif",                                 UIImage imageNamed:"campFire07.gif",                                 UIImage imageNamed:"campFire08.gif",                                 UIImage imageNamed:"campFire09.gif",                                 UIImage imageNamed:"campFire10.gif",                                 UIImage imageNamed:"campFire11.gif",                                 UIImage imageNamed:"campFire12.gif",                                 UIImage imageNamed:"campFire13.gif",                                 UIImage imageNamed:"campFire14.gif",                                 UIImage imageNamed:"campFire15.gif",                                 UIImage imageNamed:"campFire16.gif",                                 UIImage imageNamed:"campFire17.gif", nil;          / all frames will execute in 1.75 seconds     campFireView.animationDuration = 1.75;     / repeat the annimation forever     campFireView.animationRepeatCount = 0;     / start animating     campFireView startAnimating;     / add the animation view to the main window     self.view addSubview:campFireView;(2)下载图片文件 images.zip 把下载好的文件解压储存在与程序同一文件夹里在xcode - Group & Files - 在文件夹 Resource 上按鼠标右键Add->Existing files 选择下载好的Defult.png 图片;                               同上在文件夹Resource 上按鼠标右键 Add-> New Group,  命名为images;                                    在 文件夹images  上按鼠标右键 Add->Existing files 选择下载好的在images里的所有图片。最后在xCode 选择 Build->Build and Go, save all 保存所有文件下载今天程序文件: Bonfire.zip实例 iPhone SDK 编程入门教程 - 第三天DAY THREE - OPEN URL大家一起来建立一个 iPhone app,给你的iPhone打开google地图有效地址连接。首先运行以安装好的 xCode选择: File->New Project.从 "New Project" 窗口  选择 : iPhone OS ->Applications-> View-Based Application命名 : 我这里命名为 "OpenURL"(1)  在xCode打开 OpenURLViewController.h 文件,加入下面红色代码#import <UIKit/UIKit.h>imterface OpenURLViewController : UIViewController-(IBaction)openMaps;end (2)  在xCode打开 OpenURLViewController.m 文件,加入下面红色代码#import <UIKit/UIKit.h#import "Day3ViewController.h"implementation Day3ViewController/ The designated initializer. Override to perform setup that is required before the view is loaded.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil     if (self = super initWithNibName:nibNameOrNil bundle:nibBundleOrNil)         / Custom initialization        return self;-(IBAction)openMaps     NSString* addressText = "1 Queen st, Auckland, NZ"    addressText = addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding;    NSString* urlText = NSString stringWithFormat:"    /NSlog(urlText);    UIApplication sharedApplication openURL:NSURL URLWithString:urlText;/ Override to allow orientations other than the default portrait orientation.- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation     / Return YES for supported orientations    return (interfaceOrientation = UIInterfaceOrientationPortrait);- (void)didReceiveMemoryWarning     super didReceiveMemoryWarning; / Releases the view if it doesn't have a superview    / Release anything that's not essential, such as cached data- (void)dealloc     super dealloc;end(3) UIView 界面设置- 黑色背景,红色字体,让它看起来像一个闹钟。双击文件: "OpenURLViewController.xib" ;然后 "Interface Builder"  会自动打开,在这里我们可以编辑改变界面 选择: Tools -> Reveal In Document Window -> View选择:  Tools -> Attributes Inspector在色条内选择 "黑色",可以看到背景变为黑色(4) 加入 Button ,点击后打开连接选择: Tools -> Library ;从Library显示菜单中拖拉一个 Button 到 Main View在主显示上点击 Button;从Button Attributes 里面Title内填上 "Open Google Map"。(5)从 Interface Builder 写入 UIButton 的 class file再打开SDK工具 Interface Builder在主视窗口或文件窗口;点击 Button选择: Tools -> Connection Inspector移动鼠标在"Touch Up Inside" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner"放开鼠标选择键出现 "openMaps" 选上它。选择: File -> Save then close Interface Builde 最后在 xCode 选择 Build->Build and Go 下载今天程序文件: OpenURL.zip 实例 iPhone SDK 编程入门教程 - 第四天DAY Four What is my IP?大家一起来建立一个 iPhone app,给你的iPhone显示 现时 的ip地址。首先运行以安装好的 xCode选择: File->New Project.从 "New Project" 窗口  选择 : iPhone OS ->Applications-> View-Based Application命名 : 我这里命名为 "MYIP"(1)  在xCode打开 MYIPViewController.h 文件,加入下面红色代码#import <UIKit/UIKit.h>imterface OpenURLViewController : UIViewController      IBOutlet UILabel *showIPlabel;end (2)  在xCode打开 MYIPViewController.m 文件,加入下面红色代码#import <UIKit/UIKit.h#import "MYIPViewController.h"implementation MYIPViewController/ The designated initializer. Override to perform setup that is required before the view is loaded.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil     if (self = super initWithNibName:nibNameOrNil bundle:nibBundleOrNil)        showIPlabel.text = ""         return self;-(NSString *)getAddress         char iphone_ip255;    strcpy(iphone_ip,"127.0.0.1"); / if everything fails        NSHost* myhost =NSHost currentHost;        if (myhost)                      NSString *ad = myhost address;     if (ad)                     strcpy(iphone_ip,ad cStringUsingEncoding:NSASCIIStringEncoding);                return NSString stringWithFormat:"%s",iphone_ip;- (void)viewDidLoad         NSString* address = self getAddress;        NSString* myIPAdress = NSString stringWithFormat:"IP Address: %", address;        showIPlabel.text = myIPAdress;    super viewDidLoad;/ Override to allow orientations other than the default portrait orientation.- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation     / Return YES for supported orientations    return (interfaceOrientation = UIInterfaceOrientationPortrait);- (void)dealloc     super dealloc;end (3) UIView 界面设置双击文件: "MYIPViewController.xib" ;然后 "Interface Builder"  会自动打开,在这里我们可以编辑改变界面 (4) 加入 Label ,显示iPhone 的IP地址选择: Tools -> Library ; 从Library显示菜单中拖拉一个 Label 到 Main View(5)从 Interface Builder 写入 UILabel 的 class fileSDK工具 Interface Builder在主视窗口或文件窗口;点击 Label选择: Tools -> Connection Inspector移动鼠标在"Touch Up Inside" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner"放开鼠标选择键出现 "showIPlabel" 选上它。选择: File -> Save then close Interface Builde 以上几步,已成功完成界面了,下面我们继续把程式添加我们的代码文件。最后在 xCode 选择Build->Build and Go 下载今天程序文件: WhatIsMyIp.zip 实例 iPhone SDK 编程入门教程 - 第五天DAY Five Count Me In今天给你的iPhone 制作一个简单的数数程序。 纲要:在程序显示前运行代码;UIButton, UILabel, UIImageView 的运用;把integer转换为string;首先运行以安装好的 xCode选择: File->New Project.从 "New Project" 窗口  选择 : iPhone OS ->Applications-> View-Based Application命名 : 我这里命名为 “CountMeIn” (1)  在xCode打开 CountMeInViewController.h 文件,加入下面代码#import <UIKit/UIKit.h> interface CountMeInViewController : UIViewController         IBOutlet UILabel *counter;-(IBAction)reset;-(IBAction)addUnit;-(IBAction)subtractUnit; end (2)  在xCode打开 CountMeInViewController.m 文件,加入下面代码#import "CountMeInViewController.h" implementation CountMeInViewController int count = 0; -(IBAction)reset        count = 0;        counter.text = "0"        - (IBAction)addUnit                if(count >= 999) return;               NSString *numValue = NSString alloc initWithFormat:"%d", count+;        counter.text = numValue;        numValue release; - (IBAction)subtractUnit                if(count <= 0) return;               NSString *numValue = NSString alloc initWithFormat:"%d", count-;        counter.text = numValue;        numValue release;    / The designated initializer. Override to perform setup that is required before the view is loaded.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil     if (self = super initWithNibName:nibNameOrNil bundle:nibBundleOrNil)         / Custom initialization        return self;/ Implement viewDidLoad to do additional setup after loading the view, typically from a nib.- (void)viewDidLoad         counter.text = "0"    super viewDidLoad;/ Override to allow orientations other than the defa

    注意事项

    本文(实例iPhone SDK 编程入门教程.doc)为本站会员(asd****56)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开