在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ iOS/ iOS - 創(chuàng)建第一個iPhone應(yīng)用
iOS - Switches(切換/開關(guān))
iOS - Labels(標(biāo)簽)
iOS - Table View(表格視圖)
IOS - 攝像頭管理
iOS - Text View(文本視圖)
IOS - 開發(fā)環(huán)境配置
iOS教程
iOS - Twitter & Facebook
iOS - UI元素
iOS - iAd 整合
IOS - 應(yīng)用程序調(diào)試
iOS - Split View(分割視圖)
iOS - Status Bar(狀態(tài)欄)
iOS - Navigation Bar(導(dǎo)航欄)
iOS - Tab bar(標(biāo)簽欄)
IOS - 文件處理
IOS - 自動布局
iOS - Image View(圖像視圖)
iOS - 應(yīng)用程序內(nèi)購買
iOS - Pickers(選取器)
iOS - Delegates實例
iOS - 創(chuàng)建第一個iPhone應(yīng)用
iOS (iPhone, iPad)教程
iOS - 發(fā)送電子郵箱(Email)
iOS - View Transitions(視圖轉(zhuǎn)換)
iOS - 內(nèi)存管理
iOS - Icons(圖標(biāo))
iOS - 音頻和視頻
iOS - Storyboards(演示圖板演)
iOS - Buttons(按鈕)
iOS - Text Field(文本域)
iOS - Sliders(滑動條)
iOS - Scroll View(滾動視圖)
IOS - 輸入類型 文本字段
iOS - 位置處理
iOS - Accelerometer(加速度傳感器)
IOS - 快速入門
iOS - SQLite 數(shù)據(jù)庫
iOS - GameKit
IOS - 訪問地圖
iOS - Objective-C基礎(chǔ)
iOS - Toolbar(工具欄)
IOS - 動作和插座(Outlets)
iOS - Alerts(警示)
IOS - 通用應(yīng)用程序

iOS - 創(chuàng)建第一個iPhone應(yīng)用

創(chuàng)建第一個iPhone應(yīng)用

現(xiàn)在,我們只是要創(chuàng)建一個簡單的單視圖的應(yīng)用程序(一個空白的應(yīng)用程序),只運行在iOS模擬器。

步驟如下。

1. 打開Xcode和選擇創(chuàng)建一個新的Xcode項目。

2. 然后選擇單一視圖應(yīng)用

3. 然后輸入項目名稱,即應(yīng)用程序的名稱,組織名稱和公司標(biāo)識

4. 確保使用自動引用計數(shù)的選擇,以便自動釋放分配的資源,一旦超出范圍。單擊 Next.

5. 選擇項目的目錄,并選擇create.

6. 你會看到如下的一個屏幕

在屏幕上方你將能夠選擇支持的方向,建立和釋放設(shè)置?,F(xiàn)場部署有一個目標(biāo),我們要支持設(shè)備版本,選擇4.3這是現(xiàn)在最小允許部署目標(biāo)?,F(xiàn)在這些都不是必需的,讓我們把注意力集中在運行的應(yīng)用程序。

7. 現(xiàn)在選擇iPhone模擬器在附近運行按鈕的下拉,選擇“run”。 

8. 已經(jīng)成功地運行第一個應(yīng)用程序。會得到一個輸出如下

現(xiàn)在讓我們來改變背景顏色,只是為了有一個開始界面生成器。選擇ViewController.xib。選擇“background ”選項,在右側(cè),改變顏色并運行。

在上述項目中,默認(rèn)情況下部署目標(biāo)已設(shè)定到 iOS6.0,自動布局將啟用。但是,為了確保我們的應(yīng)用程序運行的設(shè)備上運行的iOS 4.3開始,我們已經(jīng)修改了部署目標(biāo)在創(chuàng)建這個應(yīng)用程序的開始,但我們沒有禁用自動布局,禁用自動布局,我們需要取消選擇“自動布局xib文件的每個 nib,即在 inspector 復(fù)選框。 Xcode項目IDE的各個部分是下圖中(注:蘋果 Xcode4 用戶文檔)。

文件檢查器處于找到檢查器選擇欄中,如上圖所示,自動布局可以是取消選中。當(dāng)想只針對的iOS6設(shè)備,可用于自動布局。此外,將能夠使用許多新功能,如果提高到iOS6部署目標(biāo)。這里使用 iOS4.3 部署目標(biāo)。

深入挖掘的第一個iOS應(yīng)用程序的代碼

會發(fā)現(xiàn)5個不同的文件,將已生成的應(yīng)用程序,如下。

  • AppDelegate.h

  • AppDelegate.m

  • ViewController.h

  • ViewController.m

  • ViewController.xib

我們使用這些單行注釋(/ /)給下面的代碼解釋簡單的代碼解釋和重要的項目。

AppDelegate.h

// Header File that provides all UI related items. 
#import <UIKit/UIKit.h> 
 // Forward declaration (Used when class will be defined /imported in future)
@class ViewController;  

 // Interface for Appdelegate
@interface AppDelegate : UIResponder <UIApplicationDelegate>
// Property window 
@property (strong, nonatomic) UIWindow *window; 
 // Property Viewcontroller
@property (strong, nonatomic) ViewController *viewController;
//this marks end of interface 
@end  
重要項目代碼
  • AppDelegate中繼承自UIResponder的處理??的iOS事件

  • 實現(xiàn) UIApplication委托的委托方法提供關(guān)鍵的應(yīng)用程序事件等成品發(fā)起,終止等。

  • 一個UIWindow對象來管理和協(xié)調(diào)各方面的意見在iOS設(shè)備上屏幕。這就像所有其他加載意見的基礎(chǔ)視圖。在一般情況下只有一個應(yīng)用程序的一個窗口。

  • UIViewController 處理??畫面流暢。

AppDelegate.m

// Imports the class Appdelegate's interface
import "AppDelegate.h" 

// Imports the viewcontroller to be loaded
#import "ViewController.h" 

// Class definition starts here
@implementation AppDelegate 


// Following method intimates us the application launched  successfully 
- (BOOL)application:(UIApplication *)application 
 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
    self.window = [[UIWindow alloc] initWithFrame:
	[[UIScreen mainScreen] bounds]]; 
    // Override yiibai for customization after application launch.
    self.viewController = [[ViewController alloc] 
	 initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    /* Sent when the application is about to move from active to inactive state.
    This can occur for certain types of temporary interruptions
    (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. Use this method to pause ongoing tasks, disable timers, 
    and throttle down OpenGL ES frame rates. Games should use this method 
    to pause the game.*/
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /* Use this method to release shared resources, save user data, invalidate 
    timers, and store enough application state information	to restore your
    application to its current state in case it is terminated later. If your 
    application supports background execution, this method is called instead 
    of applicationWillTerminate: when the user quits.*/
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    /* Called as part of the transition from the background to the inactive state;
    here you can undo many of the changes made on entering the background.*/
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /* Restart any tasks that were paused (or not yet started) while the
    application was inactive. If the application was previously in the background, 
	optionally refresh the user interface.*/
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    /* Called when the application is about to terminate. Save data if appropriate.
    See also applicationDidEnterBackground:. */
}

@end
重要項目代碼
  • 這里的UIApplication定義的委托。上述定義的所有方法是用戶界面應(yīng)用程序代表和不包含任何用戶定義的方法。

  • UIWindow中分配對象來保存應(yīng)用程序被分配

  • UIViewController的分配窗口的初始視圖控制器。

  • 為了使窗口的可見makeKeyAndVisible方法被調(diào)用。

ViewController.h

#import  

// Interface for class ViewController
@interface ViewController : UIViewController 

@end
重要項目代碼
  • ViewController 類繼承的UIViewController為iOS應(yīng)用程序提供了基本的視圖管理模式。

ViewController.m

#import "ViewController.h"

// Category, an extension of ViewController class
@interface ViewController ()

@end

@implementation ViewController  

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemory