详解iPhone开发入门教程 新手必看

移动开发 iOS
本文介绍的是详解iPhone开发入门教程 新手必看,作为新手,你不得不看,很详细的从思路开始帮你学习iphone开发基础,来看内容。

详解iPhone开发入门教程 新手必看是本文要介绍的内容,本文是在坛子上看到的一篇关于iphone开发基础教程的,主要讲解iphone开发的思想和一些简单的实现。来看详细内容。先来推荐一篇 iPhone开发入门教程 图解,可以作为参考!

思路:

(1)Interface Builder制作界面

(2)头文件中增加Outlet和事件响应函数

(3)建立界面与代码的关联

(4)添加实际代码(初始化、按键响应等)

效果: (第二张图单击可放大)

详解iPhone开发入门教程 新手必看 

详解iPhone开发入门教程 新手必看

代码:

Java代码 

  1.  
  2. //     
  3. //  QuizAppDelegate.h     
  4. //  Quiz     
  5. //     
  6. //  Created by bruce.lin on 6/21/11.     
  7. //  Copyright 2011 __MyCompanyName__. All rights reserved.     
  8. //     
  9.     
  10. #import <UIKit/UIKit.h>     
  11.     
  12. @interface QuizAppDelegate : NSObject <UIApplicationDelegate> {     
  13.     
  14.     int currentQuestionIndex;     
  15.          
  16.     NSMutableArray *questions;     
  17.     NSMutableArray *answers;     
  18.          
  19.     IBOutlet UILabel *questionField;     
  20.     IBOutlet UILabel *answerField;     
  21.          
  22.     UIWindow *window;     
  23. }     
  24.     
  25. @property (nonatomic, retain) IBOutlet UIWindow *window;     
  26.     
  27. -(IBAction) showQuestion:(id)sender;     
  28. -(IBAction) showAnswer:(id)sender;     
  29.     
  30. @end    
  31.     
  32. //     
  33. //  QuizAppDelegate.m     
  34. //  Quiz     
  35. //     
  36. //  Created by bruce.lin on 6/21/11.     
  37. //  Copyright 2011 __MyCompanyName__. All rights reserved.     
  38. //     
  39.     
  40. #import "QuizAppDelegate.h"    
  41.     
  42. @implementation QuizAppDelegate     
  43.     
  44.     
  45. @synthesize window=_window;     
  46.     
  47.     
  48. -(id)init     
  49. {     
  50.     [super init];     
  51.     questions=[[NSMutableArray alloc] init];     
  52.     answers=[[NSMutableArray alloc] init];     
  53.     
  54.     [questions addObject:@"iPhone多少米?"];     
  55.     [answers addObject:@"为啥告诉你"];     
  56.          
  57.     [questions addObject:@"路边野花不要采"];     
  58.     [answers addObject:@"一只红杏出墙来"];     
  59.          
  60.     currentQuestionIndex=0;     
  61.          
  62.     return self;     
  63. }     
  64.     
  65.     
  66. -(IBAction) showQuestion:(id)sender     
  67. {     
  68.     currentQuestionIndex++;     
  69.          
  70.     if(currentQuestionIndex >= [questions count])     
  71.     {     
  72.         currentQuestionIndex=0;     
  73.     }     
  74.          
  75.     [questionField setText:[questions objectAtIndex:currentQuestionIndex]];     
  76.          
  77.     NSLog(@"Current question is: %@",[questions objectAtIndex:currentQuestionIndex]);     
  78.          
  79.     [answerField setText:@"?"];     
  80. }     
  81.     
  82. -(IBAction) showAnswer:(id)sender     
  83. {     
  84.     [answerField setText:[answers objectAtIndex:currentQuestionIndex]];     
  85. }     
  86.     
  87.     
  88. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions     
  89. {     
  90.     // Override point for customization after application launch.     
  91.     [self.window makeKeyAndVisible];     
  92.     return YES;     
  93. }     
  94.     
  95. - (void)applicationWillResignActive:(UIApplication *)application     
  96. {     
  97.     /*    
  98.      Sent when the application is about to move from active to inactive state. 
  99. This can occur for certain types of temporary interruptions 
  100. (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.    
  101.      Use this method to pause ongoing tasks, disable timers, 
  102. and throttle down OpenGL ES frame rates. Games should use this method to pause the game.    
  103.      */    
  104. }     
  105.     
  106. - (void)applicationDidEnterBackground:(UIApplication *)application     
  107. {     
  108.     /*    
  109.      Use this method to release shared resources, save user data, invalidate timers,
  110.  and store enough application state information to restore your application to its current state in case it is terminated later.     
  111.      If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.    
  112.      */    
  113. }     
  114.     
  115. - (void)applicationWillEnterForeground:(UIApplication *)application     
  116. {     
  117.     /*    
  118.      Called as part of the transition from the background to the inactive state;
  119.  here you can undo many of the changes made on entering the background.    
  120.      */    
  121. }     
  122.     
  123. - (void)applicationDidBecomeActive:(UIApplication *)application     
  124. {     
  125.     /*    
  126.      Restart any tasks that were paused (or not yet started) while the application was inactive. 
  127. If the application was previously in the background, optionally refresh the user interface.    
  128.      */    
  129. }     
  130.     
  131. - (void)applicationWillTerminate:(UIApplication *)application     
  132. {     
  133.     /*    
  134.      Called when the application is about to terminate.    
  135.      Save data if appropriate.    
  136.      See also applicationDidEnterBackground:.    
  137.      */    
  138. }     
  139.     
  140. - (void)dealloc     
  141. {     
  142.     [_window release];     
  143.     [super dealloc];     
  144. }     
  145. @end  

小结:详解iPhone开发入门教程 新手必看的内容介绍完了,通过本文介绍的iphone开发基础,是不是学习到了一些内容,那么希望本文对你有所帮助!

责任编辑:zhaolei 来源: ITEYE论坛
相关推荐

2011-07-21 10:29:18

iPhone 开发

2011-09-07 11:13:27

无线路由器无线路由器设置

2011-07-18 14:15:55

iPhone iPad GIS

2010-07-27 15:53:15

2011-06-16 09:53:25

Qt QML 教程

2011-06-16 09:40:53

QML 教程

2011-06-16 09:28:14

Qt QML 教程

2010-08-02 09:36:22

Flex

2011-06-27 14:56:46

Qt Designer

2011-05-31 16:47:47

SEO

2010-06-13 09:45:35

Widget开发

2009-06-02 14:46:26

Hibernate关系映射教程

2013-09-18 14:46:32

StormStorm集群

2011-07-04 17:26:00

Qt SQLite

2023-11-29 07:30:08

Python用户界面

2011-08-22 12:01:38

iPhone开发文件

2011-06-23 10:12:57

SEO网站建设

2011-07-11 09:58:52

2014-05-26 15:35:55

Web组件Web Compone

2009-07-08 15:12:48

Java Servle
点赞
收藏

51CTO技术栈公众号