SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Class 09
iOS 應⽤用軟體設計
內容⼤大綱
•   Storyboard 初探
    •   QV091:Storyboard 及轉場效果
    •   QV109:Static Table (懶⼈人表格)
•   多畫⾯面之切換及轉場動畫
    •   QV035:兩個畫⾯面的切換
    •   QV036:幾種不同的畫⾯面切換⽅方式
•   網⾴頁⾴頁⾯面切換
    •   QV042:UIWebView ⽤用法
        (結合 UISegmentedcontrol 讀取外部網⾴頁)
    •   Samples:TBHintView (3rd Party ActionSheet)
Storyboard 初探
Project QV091


Storyboard
轉場效果
使⽤用 Storyboards




產⽣生檔案
MainStoryboard.storyboard




                    拖移產⽣生新的
                    View Controller
各別 UIViewController
 及內部物件的設計
(1) 按住 Ctrol,滑⿏鼠按下後從
  按鈕拖移到右邊 UIView




                 (2) 選擇 Modal
選擇 Modal Segue
(接⼊入下個樂章,轉場)      設定轉場效果
同理,製作返回功能
四種轉場效果

Cover Vertical (垂直翻⾴頁)
Flip Horizonal (⽔水平翻轉)
Cross Dissolve (⼗十字溶解)
Partial Curl (部份捲曲)
Static table
(懶⼈人表格)
Project QV109


Storyboard
Static Table
拖移 Table View Controller 進來
設定屬性:Static Cells、
選擇 TableView    區段數⺫⽬目、群組⾵風格
設注意分別選擇:
                      均有不同的屬性
(1) Table View
                      內容可以設定
(2) Table View Cell
(3) Label
表格內各格⼦子點選後顯⽰示的畫⾯面,亦可採⽤用設定完成
多畫⾯面之切換及轉場動畫
Project QV035


兩個畫⾯面間的切換
⾴頁⾯面切換之Animation動畫
UIView 切換動畫相關之⽅方法

+ (void) beginAnimation
+ (void) setAnimationDuration
+ (void) setAnimationCurve
+ (void) setAnimationTransition
+ (void) commitAnimations
動畫切換之過渡效果

UIViewAnimationTransitionFlipFromLeft (從左側翻轉)
UIViewAnimationTransitionFlipFromRight (從右側翻轉)
UIViewAnimationTransitionCurlUp (往上捲起)
UIViewAnimationTransitionCurlDown (往下捲起)
UIViewAnimationTransitionNone (無效果)
ViewController.h



#import <UIKit/UIKit.h>
@class SwitchView;

@interface ViewController : UIViewController
{
    SwitchView *switchView;
}

@end
ViewController.m (1/2)
#import "ViewController.h"
#import "SwitchView.h"

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    myButton.frame = CGRectMake(120, 250, 80, 40);
    [myButton setTitle:@"Switch" forState:UIControlStateNormal];
    [myButton addTarget:self
                 action:@selector(onSwitch:)
       forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview: myButton];

    self.view.backgroundColor = [UIColor redColor];
}
ViewController.m (2/2)


- (void)onSwitch:(id)sender
{
! switchView = [[SwitchView alloc]
                 initWithNibName:@"SwitchView" bundle:nil];

! [self.view addSubview:switchView.view];

!   // 加⼊入動畫
!   [UIView beginAnimations:@"flipview" context:nil];
!   [UIView setAnimationDuration:0.5];
!   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
!   [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
!   !   ! ! ! !        forView:self.view cache:YES];

! [UIView commitAnimations];
}
SwitchView.h




#import <UIKit/UIKit.h>

@interface SwitchView : UIViewController

-(void) onBack:(id)sender;

@end
- (void)viewDidLoad
{                                                      SwitchView.m
    [super viewDidLoad];

    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    myButton.frame = CGRectMake(120, 350, 80, 40);
    [myButton setTitle:@"Back" forState:UIControlStateNormal];
    [myButton addTarget:self
                 action:@selector(onBack:)
       forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview: myButton];
    self.view.backgroundColor = [UIColor blueColor];
}


- (void)onBack:(id)sender
{
! [UIView beginAnimations:@"flipview" context:nil];
! [UIView setAnimationDuration:5];
! [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
! [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
! !   ! ! ! !        forView:self.view.superview cache:YES];

    [self.view removeFromSuperview];

    [UIView commitAnimations];
}
Project QV036
簡單的兩個⾴頁⾯面切換,但改
⽤用xib處理畫⾯面
三種常⽤用⽅方法
addSubView
presentModalViewController
presentViewController
畫⾯面間的切換
⽅方法⼀一:視為⼦子畫⾯面新增加⼊入



        [A.view addSubview:B.view]




       [B.view removeFromSuperview]
⽅方法⼆二:presentModalViewController
           注意:已在 iOS5 中移除




      [A presentModalViewController:B animated:]




       [B dismissModalViewControllerAnimated:]
⽅方法三:presentViewController

           [A presentViewController:B
             animated: completion:]




        [B dismissViewControllerAnimated:
                  completion:]




                                 包含切換完成後的處理程序
討論問題


presentView 適⽤用時機?
presentView 和 ActionSheet 之異同?
網⾴頁切換 UIWebView

• QV042:UIWebView ⽤用法
 (結合 UISegmentedcontrol 讀取外部網⾴頁)
Project QV042

點選項⺫⽬目按鈕,進⼊入網站
UISegmentedControl
UIWebView
連結外部網站與內部網⾴頁檔
ViewController.h



#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    IBOutlet UISegmentedControl *segmentedControl;
    IBOutlet UIWebView *webView;

    NSArray *nameArray;
    NSArray *linkArray;
}

- (IBAction) change:(id)sender;

@end
ViewController.xib
ViewController.m (1/2)
  - (void)viewDidLoad
  {
      [super viewDidLoad];

      //建⽴立陣列並設定其內容來當作選項
      nameArray =[NSArray arrayWithObjects:
                           @"三寶家庭",
                           @"Yahoo!",
                           @"Google",
                           @"Apple",
                           nil];
                                                   在迴圈內逐⼀一指定
   linkArray =[NSArray arrayWithObjects:
                        @"page1",
                        @"http://www.yahoo.com.tw/",
內部檔案之主檔名                @"http://www.google.com/",
                        @"http://www.apple.com/",
                        nil];

      //使⽤用陣列來建⽴立UISegmentedControl
      for(int i=0; i<segmentedControl.numberOfSegments; i++)
      {
          NSString *str = [nameArray objectAtIndex:i];
          [segmentedControl setTitle:str forSegmentAtIndex:i];
      }
      // segmentedControl.selectedSegmentIndex = 2;
  }
ViewController.m (2/2)
- (IBAction)change:(id)sender
{
    NSString *link = [linkArray objectAtIndex:[sender
selectedSegmentIndex]];
    NSString *str1 = [link substringToIndex:4];
    NSString *str2 = [NSString stringWithFormat:@"http"];

    if([str1 isEqualToString:str2])
    {
        // 讀網⾴頁
         [webView loadRequest:[NSURLRequest
                          requestWithURL:[NSURL URLWithString:link]]];
    }
    else
    {
        // 讀檔案
         [webView loadRequest:[NSURLRequest requestWithURL:[NSURL
                         fileURLWithPath:[[NSBundle mainBundle]
                         pathForResource:link
                                  ofType:@"htm"]isDirectory:NO]]];

    }
}
問題

是否可以使⽤用陣列來定義按鈕的項⺫⽬目?
參考:關於 UISegmentedControl 的基
本設定⽅方式
(http://furnacedigital.blogspot.com/2011/08/uisegmentedcontrol.html)




網⾴頁切換有其它的⽅方法嗎?
範例:
      TBHintView
 3rd Party : ActionSheet
http://furnacedigital.blogspot.com/2012/05/tbhintview-uiactionsheet.html
............

Weitere ähnliche Inhalte

Was ist angesagt?

06 Subclassing UIView and UIScrollView
06 Subclassing UIView and UIScrollView06 Subclassing UIView and UIScrollView
06 Subclassing UIView and UIScrollViewTom Fan
 
Script with engine
Script with engineScript with engine
Script with engineWebrebuild
 
09 UITableView and UITableViewController
09 UITableView and UITableViewController09 UITableView and UITableViewController
09 UITableView and UITableViewControllerTom Fan
 
Kissy简介
Kissy简介Kissy简介
Kissy简介jay li
 
Asp.net開發要注意的是?
Asp.net開發要注意的是?Asp.net開發要注意的是?
Asp.net開發要注意的是?Rainmaker Ho
 
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染Sheng-Han Su
 
15 Subclassing UITableViewCell
15 Subclassing UITableViewCell15 Subclassing UITableViewCell
15 Subclassing UITableViewCellTom Fan
 
07 View Controllers
07 View Controllers07 View Controllers
07 View ControllersTom Fan
 
程式人雜誌 2015年三月
程式人雜誌 2015年三月程式人雜誌 2015年三月
程式人雜誌 2015年三月鍾誠 陳鍾誠
 
jQuery 選取器解析
jQuery 選取器解析jQuery 選取器解析
jQuery 選取器解析Kingsley Zheng
 
YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用Adam Lu
 
程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號鍾誠 陳鍾誠
 
08 Notification and Rotation
08 Notification and Rotation08 Notification and Rotation
08 Notification and RotationTom Fan
 

Was ist angesagt? (15)

06 Subclassing UIView and UIScrollView
06 Subclassing UIView and UIScrollView06 Subclassing UIView and UIScrollView
06 Subclassing UIView and UIScrollView
 
Script with engine
Script with engineScript with engine
Script with engine
 
09 UITableView and UITableViewController
09 UITableView and UITableViewController09 UITableView and UITableViewController
09 UITableView and UITableViewController
 
Kissy简介
Kissy简介Kissy简介
Kissy简介
 
I os 01
I os 01I os 01
I os 01
 
Asp.net開發要注意的是?
Asp.net開發要注意的是?Asp.net開發要注意的是?
Asp.net開發要注意的是?
 
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
 
15 Subclassing UITableViewCell
15 Subclassing UITableViewCell15 Subclassing UITableViewCell
15 Subclassing UITableViewCell
 
I os 10
I os 10I os 10
I os 10
 
07 View Controllers
07 View Controllers07 View Controllers
07 View Controllers
 
程式人雜誌 2015年三月
程式人雜誌 2015年三月程式人雜誌 2015年三月
程式人雜誌 2015年三月
 
jQuery 選取器解析
jQuery 選取器解析jQuery 選取器解析
jQuery 選取器解析
 
YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用
 
程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號
 
08 Notification and Rotation
08 Notification and Rotation08 Notification and Rotation
08 Notification and Rotation
 

Andere mochten auch (11)

I os 04
I os 04I os 04
I os 04
 
課程規畫
課程規畫課程規畫
課程規畫
 
I os 16
I os 16I os 16
I os 16
 
I os 05
I os 05I os 05
I os 05
 
I os 02
I os 02I os 02
I os 02
 
I os 11
I os 11I os 11
I os 11
 
I os 03
I os 03I os 03
I os 03
 
I os 15
I os 15I os 15
I os 15
 
I os 08
I os 08I os 08
I os 08
 
I os 06
I os 06I os 06
I os 06
 
I os 13
I os 13I os 13
I os 13
 

Ähnlich wie I os 09

YUIconf2010介绍
YUIconf2010介绍YUIconf2010介绍
YUIconf2010介绍ling yu
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文Guo Albert
 
Android 智慧型手機程式設計
Android 智慧型手機程式設計Android 智慧型手機程式設計
Android 智慧型手機程式設計Kyle Lin
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing江華 奚
 
掌星 移动互联网开发笔记-Vol001
掌星 移动互联网开发笔记-Vol001掌星 移动互联网开发笔记-Vol001
掌星 移动互联网开发笔记-Vol001rainx1982
 
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端 用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端 升煌 黃
 
JdonFramework中文
JdonFramework中文JdonFramework中文
JdonFramework中文banq jdon
 
Core data lightweight_migration
Core data lightweight_migrationCore data lightweight_migration
Core data lightweight_migrationMichael Pan
 
13 UIPopoverController and Modal View Controller
13 UIPopoverController and Modal View Controller13 UIPopoverController and Modal View Controller
13 UIPopoverController and Modal View ControllerTom Fan
 
透過 Windows Azure Mobile Services 開發各平台 Apps
透過 Windows Azure Mobile Services 開發各平台 Apps透過 Windows Azure Mobile Services 開發各平台 Apps
透過 Windows Azure Mobile Services 開發各平台 AppsEric ShangKuan
 
105-2 iOS程式設計(六)
105-2 iOS程式設計(六)105-2 iOS程式設計(六)
105-2 iOS程式設計(六)Hao Lee
 
Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1modou li
 
怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google Maps怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google MapsWeizhong Yang
 
Backbone.js and MVW 101
Backbone.js and MVW 101Backbone.js and MVW 101
Backbone.js and MVW 101Jollen Chen
 
Unity遊戲程式設計 - 應用Sprite物件
Unity遊戲程式設計 - 應用Sprite物件Unity遊戲程式設計 - 應用Sprite物件
Unity遊戲程式設計 - 應用Sprite物件吳錫修 (ShyiShiou Wu)
 
2016輕鬆開發自有網路地圖工作坊 進階班 0701
2016輕鬆開發自有網路地圖工作坊 進階班 07012016輕鬆開發自有網路地圖工作坊 進階班 0701
2016輕鬆開發自有網路地圖工作坊 進階班 0701family
 
Backbone js and requirejs
Backbone js and requirejsBackbone js and requirejs
Backbone js and requirejsChi-wen Sun
 
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式Shengyou Fan
 
ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展江華 奚
 

Ähnlich wie I os 09 (20)

005
005005
005
 
YUIconf2010介绍
YUIconf2010介绍YUIconf2010介绍
YUIconf2010介绍
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文
 
Android 智慧型手機程式設計
Android 智慧型手機程式設計Android 智慧型手機程式設計
Android 智慧型手機程式設計
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
 
掌星 移动互联网开发笔记-Vol001
掌星 移动互联网开发笔记-Vol001掌星 移动互联网开发笔记-Vol001
掌星 移动互联网开发笔记-Vol001
 
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端 用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
 
JdonFramework中文
JdonFramework中文JdonFramework中文
JdonFramework中文
 
Core data lightweight_migration
Core data lightweight_migrationCore data lightweight_migration
Core data lightweight_migration
 
13 UIPopoverController and Modal View Controller
13 UIPopoverController and Modal View Controller13 UIPopoverController and Modal View Controller
13 UIPopoverController and Modal View Controller
 
透過 Windows Azure Mobile Services 開發各平台 Apps
透過 Windows Azure Mobile Services 開發各平台 Apps透過 Windows Azure Mobile Services 開發各平台 Apps
透過 Windows Azure Mobile Services 開發各平台 Apps
 
105-2 iOS程式設計(六)
105-2 iOS程式設計(六)105-2 iOS程式設計(六)
105-2 iOS程式設計(六)
 
Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1
 
怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google Maps怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google Maps
 
Backbone.js and MVW 101
Backbone.js and MVW 101Backbone.js and MVW 101
Backbone.js and MVW 101
 
Unity遊戲程式設計 - 應用Sprite物件
Unity遊戲程式設計 - 應用Sprite物件Unity遊戲程式設計 - 應用Sprite物件
Unity遊戲程式設計 - 應用Sprite物件
 
2016輕鬆開發自有網路地圖工作坊 進階班 0701
2016輕鬆開發自有網路地圖工作坊 進階班 07012016輕鬆開發自有網路地圖工作坊 進階班 0701
2016輕鬆開發自有網路地圖工作坊 進階班 0701
 
Backbone js and requirejs
Backbone js and requirejsBackbone js and requirejs
Backbone js and requirejs
 
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
 
ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展
 

Mehr von 信嘉 陳

Mehr von 信嘉 陳 (12)

Processing 06
Processing 06Processing 06
Processing 06
 
Processing 05
Processing 05Processing 05
Processing 05
 
Processing 04
Processing 04Processing 04
Processing 04
 
Processing 03
Processing 03Processing 03
Processing 03
 
Processing 02
Processing 02Processing 02
Processing 02
 
Processing 01
Processing 01Processing 01
Processing 01
 
Processing 09
Processing 09Processing 09
Processing 09
 
Processing 08
Processing 08Processing 08
Processing 08
 
Processing 07
Processing 07Processing 07
Processing 07
 
Google 街景
Google 街景Google 街景
Google 街景
 
社群網站 Facebook
社群網站 Facebook社群網站 Facebook
社群網站 Facebook
 
網路搜尋
網路搜尋網路搜尋
網路搜尋
 

I os 09