歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> iOS入門教程之打開照相機與本地相冊選擇圖片

iOS入門教程之打開照相機與本地相冊選擇圖片

日期:2017/3/1 9:47:30   编辑:Linux編程

如下圖所示 在本地相冊中選擇一張圖片後,我們將他拷貝至沙盒當中,在客戶端中將它的縮略圖放在按鈕旁邊,這個結構其實和新浪微薄中選擇圖片後的效果一樣。最終點擊發送將按鈕將圖片2進制圖片上傳服務器。

源碼下載地址

免費下載地址在 http://linux.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /2014年資料/3月/6日/iOS入門教程之打開照相機與本地相冊選擇圖片

下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm

下面我們仔細學習具體的細節。創建一個空的IOS項目,接著在創建一個ViewController。

AppDelegate.h 應用的代理類 這個沒什麼好說的就是直接打開剛剛創建的新ViewController。

AppDelegate.h 應用的代理類 這個沒什麼好說的就是直接打開剛剛創建的新ViewController。

#import <UIKit/UIKit.h>

#import "TestViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) UINavigationController *navController;

@property (strong, nonatomic) UIViewController *viewController;

@end

pDelegate.m 在這裡就是打開我們創建的TestViewController

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window = _window;

@synthesize navController;

@synthesize viewController;

- (void)dealloc

{

[_window release];

[super dealloc];

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

self.window.backgroundColor = [UIColor whiteColor];

self.viewController = [[TestViewController alloc]init];

self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];

[self.window addSubview:navController.view];

[self.window makeKeyAndVisible];

return YES;

}

@end

Copyright © Linux教程網 All Rights Reserved