麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

從零開始學(xué)ios開發(fā)(十五):NavigationControllersandTableViews(中)

2019-11-14 20:20:04
字體:
供稿:網(wǎng)友

這篇內(nèi)容我們繼續(xù)上一篇的例子接著做下去,為其再添加3個table view的例子,有了之前的基礎(chǔ),學(xué)習(xí)下面的例子會變得很簡單,很多東西都是舉一反三,稍稍有些不同的內(nèi)容,好了,閑話少說,開始這次的學(xué)習(xí)。

如果沒有上一篇的代碼,可以從這里下載Nav_1

1)第三個subtableview:Controls on Table Rows
這個例子,我們將為每個table view的每一行添加一個按鈕,這個按鈕將放在accessory icon的位置(之前我們使用過accessoryType,其實這也是一個view,可以容納其他的view,因此我們將一個button放在其中,然后accessory icon的位置上就會顯示button了,看了后面的例子就會明白)

同樣,選中PRoject navigator中的Nav文件夾,單擊鼠標(biāo)右鍵,選擇“New File...”,在彈出的窗口中,左邊選擇Cocoa Touch,右邊選擇Objective-C class,點擊Next按鈕,在下一個窗口中將class命名為BIDRowControlsController,Subclass of命名為BIDSecondLevelViewController,點擊Next按鈕,完成創(chuàng)建。

打開BIDRowControlsController.h,添加如下代碼

復(fù)制代碼
#import "BIDSecondLevelViewController.h"@interface BIDRowControlsController : BIDSecondLevelViewController@property (strong, nonatomic) NSArray *list;- (IBAction)buttonTapped:(id)sender;@end
復(fù)制代碼

list用戶保存table view中每一行顯示的數(shù)據(jù),buttonTapped事件用于按鈕的觸發(fā),大家也可以猜到,會是一個警告框彈出。(嚴(yán)格的來說這里不指定IBAction也可以,因為我們并沒有創(chuàng)建nib,也不會拖一個button到nib上面然后與其關(guān)聯(lián),定義一個普通的沒有返回值的方法即可,但是書里面還是推薦使用IBAction關(guān)鍵詞,這樣可以方面代碼的閱讀,可以知道這個方法是用于被某個控件觸發(fā)的。樓主木有試過這個方法,大家可以試試看,哈哈)

打開BIDRowControlsController.m,添加如下代碼

復(fù)制代碼
#import "BIDRowControlsController.h"@implementation BIDRowControlsController@synthesize list;- (IBAction)buttonTapped:(id)sender{    UIButton *senderButton = (UIButton *)sender;    UITableViewCell *buttonCell = (UITableViewCell *)[senderButton superview];    NSUInteger buttonRow = [[self.tableView indexPathForCell:buttonCell] row];    NSString *buttonTitle = [list objectAtIndex:buttonRow];    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You tapped the button"                                                    message:[NSString stringWithFormat:@"You tapped the button for %@", buttonTitle]                                                   delegate:nil                                          cancelButtonTitle:@"OK"                                          otherButtonTitles:nil];    [alert show];}- (void)viewDidLoad {    [super viewDidLoad];    NSArray *array = [[NSArray alloc] initWithObjects:@"R2-D2",                      @"C3PO", @"Tik-Tok", @"Robby", @"Rosie", @"Uniblab",                      @"Bender", @"Marvin", @"Lt. Commander Data",                      @"Evil Brother Lore", @"Optimus Prime", @"Tobor", @"HAL",                      @"Orgasmatron", nil];    self.list = array;}- (void)viewDidUnload{    [super viewDidUnload];    self.list = nil;}
復(fù)制代碼

這里添加了很常見的viewDidLoad和viewDidUnload,并且實現(xiàn)了buttonTapped方法,稍微解釋一下buttonTapped方法:
UIButton *senderButton = (UIButton *)sender; // 根據(jù)sender參數(shù)來確定是哪個button觸發(fā)了該事件,然后根據(jù)button所在的
UITableViewCell *buttonCell = (UITableViewCell *)[senderButton superview]; // 獲得button的superview,因為該button是在某一個的table cell上,因此它的superview就是UITableViewCell,因此這里可以強制的將button的superview轉(zhuǎn)換成UITableViewCell對象
NSUInteger buttonRow = [[self.tableView indexPathForCell:buttonCell] row]; // 根據(jù)獲得的table cell得到indexPath,再根據(jù)indexPath獲得button具體在第幾行
NSString *buttonTitle = [list objectAtIndex:buttonRow]; // 有第幾行,就可以在list中找到對應(yīng)的字符串了

接著添加table data source方法,添加如下代碼

復(fù)制代碼
#pragma mark -#pragma mark Table Data Source Methods- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return [list count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *ControlRowIdentifier = @"ControlRowIdentifier";        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ControlRowIdentifier];    if(cell == nil) {        cell = [[UITableViewCell alloc]                initWithStyle:UITableViewCellStyleDefault                reuseIdentifier:ControlRowIdentifier];        UIImage *buttonUpImage = [UIImage imageNamed:@"button_up.png"];        UIImage *buttonDownImage = [UIImage imageNamed:@"button_down.png"];        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];        button.frame = CGRectMake(0.0, 0.0, buttonUpImage.size.width, buttonUpImage.size.height);        [button setBackgroundImage:buttonUpImage forState:UIControlStateNormal];        [button setBackgroundImage:buttonDownImage forState:UIControlStateHighlighted];        [button setTitle:@"Tap" forState:UIControlStateNormal];        [button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];        cell.accessoryView = button;    }    NSUInteger row = [indexPath row];    NSString *rowTitle = [list objectAtIndex:row];    cell.textLabel.text = rowTitle;        return cell;}
復(fù)制代碼

這2個方法也見了很多次了,對tableview:cellForRowAtIndexPath中的一些內(nèi)容進行解釋:
UIImage *buttonUpImage = [UIImage imageNamed:@"button_up.png"]; // 載入button彈起狀態(tài)時的圖片
UIImage *buttonDownImage = [UIImage imageNamed:@"button_down.png"]; // 載入button按下時的圖片
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; // 創(chuàng)建一個button,這里沒有使用一般的創(chuàng)建方法[UIButton alloc],原因是如果使用了這樣的方法創(chuàng)建button,之中對這個button的外觀、文字等就不能進行修改了,因此我們使用buttonWithType,并選擇UIButtonTypeCustom,自定義button外觀
button.frame = CGRectMake(0.0, 0.0, buttonUpImage.size.width, buttonUpImage.size.height); // 定義button的大小
[button setBackgroundImage:buttonUpImage forState:UIControlStateNormal]; // 用一張圖片設(shè)置button彈起時的狀態(tài)
[button setBackgroundImage:buttonDownImage forState:UIControlStateHighlighted]; // 用另一張圖片設(shè)置button按下時的狀態(tài)
[button setTitle:@"Tap"forState:UIControlStateNormal]; // 設(shè)置button的文字
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; // 為button添加事件,分2部分,首先是觸發(fā)哪個事件,另一個是在什么情況下觸發(fā),這里設(shè)置的觸發(fā)的事件是buttonTapped(IBAction類型,這是為什么剛才說不適用IBAction關(guān)鍵詞也可以,因為我們使用代碼的方式為button制定了觸發(fā)的方法,因此不用IBAction),當(dāng)手指在button內(nèi)部彈起時才會觸發(fā)buttonTapped事件。
cell.accessoryView = button; // 在table cell的accessoryView的位置放置button

添加table的delegate方法,代碼如下

復(fù)制代碼
#pragma mark -#pragma mark Table Delegate Methods- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    NSUInteger row = [indexPath row];    NSString *rowTitle = [list objectAtIndex:row];    UIAlertView *alert = [[UIAlertView alloc]                          initWithTitle:@"You tapped the row."                          message:[NSString stringWithFormat:@"You tapped %@.", rowTitle]                          delegate:nil                          cancelButtonTitle:@"OK"                          otherButtonTitles:nil];    [alert show];    [tableView deselectRowAtIndexPath:indexPath animated:YES];}
復(fù)制代碼

這個方法的實現(xiàn)之前也見過,就對最后一句話解釋一下:
[tableView deselectRowAtIndexPath:indexPath animated:YES]; // 當(dāng)點擊table view中的一行時,該行的背景色會變藍,這句話的作用就是使其恢復(fù)成原來未選擇時的狀態(tài)

最后打開BIDFirstLevelController.m,添加如下代碼

復(fù)制代碼
#import "BIDFirstLevelController.h"#import "BIDSecondLevelViewController.h"#import "BIDDisclosureButtonController.h"#import "BIDCheckListController.h"#import "BIDRowControlsController.h"@implementation BIDFirstLevelController@synthesize controllers;- (void)viewDidLoad {    [super viewDidLoad];    self.title = @"First Level";    NSMutableArray *array = [[NSMutableArray alloc] init];        // Disclosure Button    BIDDisclosureButtonController *disclosureButtonController = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];    disclosureButtonController.title = @"Disclosure Buttons";    disclosureButtonController.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];    [array addObject:disclosureButtonController];        // Checklist    BIDCheckListController *checkListController = [[BIDCheckListController alloc] initWithStyle:UITableViewStylePlain];    checkListController.title = @"Check One";    checkListController.rowImage = [UIImage imageNamed:@"checkmarkControllerIcon.png"];    [array addObject:checkListController];        // Row Controls    BIDRowControlsController *rowControlsController = [[BIDRowControlsController alloc] initWithStyle:UITableViewStylePlain];    rowControlsController.title = @"Row Controls";    rowControlsController.rowImage = [UIImage imageNamed:@"rowControlsIcon.png"];    [array addObject:rowControlsController];        self.controllers = array;}
復(fù)制代碼

這里就不解釋了,和之前的一樣。

編譯運行,效果如下

多了最下面的Row Controls,我們點擊改行


每一個cell都有一個我們剛才定義的button在上面

我們點擊button,顯示效果如下

我們點擊行,顯示效果如下

這個例子就如此簡單的完成了,我們接著下一個例子。

2)第四個subtableview:Movable Rows 
這個例子是用來說明如何移動table view中的每一行,可以對其重新進行排序,在table view中有一個現(xiàn)成的方法叫做setEditing:animated,用于設(shè)置table view的內(nèi)容是否可以進行編輯(edit)、刪除(delete)、插入(insert),如果我們要對table view中的內(nèi)容進行操作,我們必須設(shè)置其為true,否則table view是不能進行編輯的。這個例子中,我們將對table view中的行進行操作,因此一定要設(shè)置其為true。廢話不多說,看來下面的例子就會更加清楚,好,現(xiàn)在開始這個例子。

選中Project navigator中的Nav文件夾,單擊鼠標(biāo)右鍵,選擇“New File...”,在彈出的窗口中,左邊選擇Cocoa Touch,右邊選擇Objective-C class,點擊Next按鈕,在下一個窗口中將class命名為BIDMoveMeController,Subclass of命名為BIDSecondLevelViewController,點擊Next按鈕,完成創(chuàng)建。

打開BIDMoveMeController.h,添加如下代碼

@interface BIDMoveMeController : BIDSecondLevelViewController@property (strong, nonatomic) NSMutableArray *list;- (IBAction)toggleMove;@end

list用于保存數(shù)據(jù),這里聲明的類型是NSMutableArray,因為我們要對table view中的行進行移動,因此list的內(nèi)容會發(fā)生變化,因此需要一個可變的Array。toggleMove方法用于打開/關(guān)閉table view的編輯模式。

打開BIDMoveMeController.m,添加如下代碼

復(fù)制代碼
#import "BIDMoveMeController.h"@implementation BIDMoveMeController@synthesize list;- (IBAction)toggleMove{    [self.tableView setEditing:!self.tableView.editing animated:YES];        if(self.tableView.editing)        [self.navigationItem.rightBarButtonItem setTitle:@"Done"];    else        [self.navigationItem.rightBarButtonItem setTitle:@"Move"];}- (void)viewDidLoad {    [super viewDidLoad];    if (list == nil) {        NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:                                 @"Eeny", @"Meeny", @"Miney", @"Moe", @"Catch", @"A",                                 @"Tiger", @"By", @"The", @"Toe", nil];        self.list = array;    }        UIBarButtonItem *moveButton = [[UIBarButtonItem alloc]                                   initWithTitle:@"Move"                                   style:UIBarButtonItemStyleBordered                                   target:self                                   action:@selector(toggleMove)];    self.navigationItem.rightBarButtonItem = moveButton;}
復(fù)制代碼

先說一下toggleMove,這個方法是給navigator bar上右邊的按鈕調(diào)用的,
[self.tableView setEditing:!self.tableView.editing animated:YES]; // 通過self.tableView.editing屬性安排當(dāng)前table view的狀態(tài)是不是處于編輯模式,如果是,則變回非編輯模式,如果不是,則進入編輯模式
if(self.tableView.editing// 如果是編輯模式
    [self.navigationItem.rightBarButtonItem setTitle:@"Done"]; // 設(shè)置navigator上右邊的按鈕文字為“Done”
else // 如果不是編輯模式
    [self.navigationItem.rightBarButtonItem setTitle:@"Move"]; // 設(shè)置navigator上右邊的按鈕文字為“Move”

在viewDidLoad方法中,我們創(chuàng)建了一個button(moveButton),然后將該button賦給navigator上右邊的按鈕。

大家有沒有注意到這里我們沒有定義viewDidUnload?我們在viewDidLoad中,也沒有每次都對list進行創(chuàng)建,而是判斷l(xiāng)ist是否為nil,如果是,則生成list。我們?yōu)槭裁匆@么做呢?一個很重要的原因是之后我們將對list中的內(nèi)容進行排序,如果每次都生成新的list,那么我們剛剛排好序的list就會丟失,這個是我們不希望發(fā)生的,因此我們在這里就不對list反復(fù)的進行創(chuàng)建了。

好,接著添加如下代碼

復(fù)制代碼
#pragma mark -#pragma mark Table Data Source Methods- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return [list count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *MoveMeCellIdentifier = @"MoveMeCellIdentifier";    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MoveMeCellIdentifier];    if(cell == nil)    {        cell = [[UITableViewCell alloc]                initWithStyle:UITableViewCellStyleDefault                reuseIdentifier:MoveMeCellIdentifier];        cell.showsReorderControl = YES;    }    NSUInteger row = [indexPath row];    cell.textLabel.text = [list objectAtIndex:row];        return cell;}
復(fù)制代碼

在tableView:cellForRowAtIndexPath中,有一句新的代碼:
cell.showsReorderControl = YES; // 它的作用是顯示reorder的控件(重新排序的控件),比較奇怪的是我試過把這句話注釋掉,但是哪個排序控件依然出現(xiàn),不知道為什么。

接著添加代碼

復(fù)制代碼
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{    return UITableViewCellEditingStyleNone;}- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{    return YES;}- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath{    NSUInteger fromRow = [fromIndexPath row];    NSUInteger toRow = [toIndexPath row];        id object = [list objectAtIndex:fromRow];    [list removeObjectAtIndex:fromRow];    [list insertObject:object atIndex:toRow];}
復(fù)制代碼

上面3個方法都是第一次看見,第一個方法tableView:editingStyleForRowAtIndexPath用于制定tableview是否可以進行刪除或者插入操作,在這里我們僅僅是進行排序,所以返回的對象是UITableViewCellEditingStyleNone。第二個方法tableView:canMoveRowAtIndexPath,指定是否可以移動行。最后一個方法tableView:moveRowAtIndexPath是移動行后進行操作的方法,記錄一行的起始位置和終點,然后在list中把先備份一下起始位置的值,然后刪除,最后再終點位置插入備份值,ok,完成移動操作。怎么樣,還是很直接和簡單的吧。

打開BIDFirstLevelController.m,添加最后的代碼

復(fù)制代碼
#import "BIDFirstLevelController.h"#import "BIDSecondLevelViewController.h"#import "BIDDisclosureButtonController.h"#import "BIDCheckListController.h"#import "BIDRowControlsController.h"#import "BIDMoveMeController.h"@implementation BIDFirstLevelController@synthesize controllers;- (void)viewDidLoad {    [super viewDidLoad];    self.title = @"First Level";    NSMutableArray *array = [[NSMutableArray alloc] init];        // Disclosure Button    BIDDisclosureButtonController *disclosureButtonController = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];    disclosureButtonController.title = @"Disclosure Buttons";    disclosureButtonController.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];    [array addObject:disclosureButtonController];        // Checklist    BIDCheckListController *checkListController = [[BIDCheckListController alloc] initWithStyle:UITableViewStylePlain];    checkListController.title = @"Check One";    checkListController.rowImage = [UIImage imageNamed:@"checkmarkControllerIcon.png"];    [array addObject:checkListController];        // Row Controls    BIDRowControlsController *rowControlsController = [[BIDRowControlsController alloc] initWithStyle:UITableViewStylePlain];    rowControlsController.title = @"Row Controls";    rowControlsController.rowImage = [UIImage imageNamed:@"rowControlsIcon.png"];    [array addObject:rowControlsController];        // Move Me    BIDMoveMeController *moveMeController = [[BIDMoveMeController alloc] initWithStyle:UITableViewStylePlain];    moveMeController.title = @"Move Me";    moveMeController.rowImage = [UIImage imageNamed:@"moveMeIcon.png"];    [array addObject:moveMeController];        self.controllers = array;}
復(fù)制代碼

編譯運行

進入Move Me后

點擊navigator上右邊的Move按鈕

按鈕的文字變成了“Done”,然后tableview中每一行的右邊都出現(xiàn)了一個reorder的圖標(biāo),將手指放在上面逗留一會,你點中的那一行會“浮起”,接著你就可以隨意移動了,移到你想要的地方后放手即可。

3)第五個subtableview:Deletable Rows 
這個例子展示的是如何刪除table view中的行,這次我們不再在viewDidLoad中對table view的內(nèi)容進行定義,而是從外部的一個文件進行導(dǎo)入,首先下載這里的computers.plist.zip,解壓縮后拖入到Project navigator下的Nav文件夾下

好,下面可以開始添加新的文件了,選中Project navigator中的Nav文件夾,單擊鼠標(biāo)右鍵,選擇“New File...”,在彈出的窗口中,左邊選擇Cocoa Touch,右邊選擇Objective-C class,點擊Next按鈕,在下一個窗口中將class命名為BIDDeleteMeController,Subclass of命名為BIDSecondLevelViewController,點擊Next按鈕,完成創(chuàng)建。

打開BIDDeleteMeController.h文件,添加如下代碼

復(fù)制代碼
#import "BIDSecondLevelViewController.h"@interface BIDDeleteMeController : BIDSecondLevelViewController@property (strong, nonatomic) NSMutableArray *list;- (IBAction)toggleEdit:(id)sender;@end
復(fù)制代碼

應(yīng)該可以想到,我們肯定要聲明一個NSMutableArray,因為需要刪除其中的項,toggleEdit方法用于table view狀態(tài)的切換。

打開BIDDeleteMeController.m文件,添加如下代碼

復(fù)制代碼
#import "BIDDeleteMeController.h"@implementation BIDDeleteMeController@synthesize list;- (IBAction)toggleEdit:(id)sender{    [self.tableView setEditing:!self.tableView.editing animated:YES];        if(self.tableView.editing)        [self.navigationItem.rightBarButtonItem setTitle:@"Done"];    else        [self.navigationItem.rightBarButtonItem setTitle:@"Delete"];}- (void)viewDidLoad{    [super viewDidLoad];    if(list == nil)    {        NSString *path = [[NSBundle mainBundle] pathForResource:@"computers" ofType:@"plist"];        NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:path];        self.list = array;    }    UIBarButtonItem *editButton = [[UIBarButtonItem alloc]                                   initWithTitle:@"Delete"                                   style:UIBarButtonItemStyleDone                                   target:self                                   action:@selector(toggleEdit:)];    self.navigationItem.rightBarButtonItem = editButton;}
復(fù)制代碼

應(yīng)該不會覺得有看不懂的地方吧,和之前的一個例子是一樣的,那么就接著添加代碼吧

復(fù)制代碼
#pragma mark -#pragma mark Table Data Source Methods- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return [list count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *DeleteMeCellIdentifier = @"DeleteMeCellIdentifier";        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier];        if(cell == nil)    {        cell = [[UITableViewCell alloc]                initWithStyle:UITableViewCellStyleDefault                reuseIdentifier:DeleteMeCellIdentifier];    }        NSInteger row = [indexPath row];    cell.textLabel.text = [list objectAtIndex:row];    return cell;}
復(fù)制代碼

額~~~貌似也不用解釋,好吧,就不解釋了,繼續(xù)添加代碼

復(fù)制代碼
#pragma mark -#pragma mark Table View Data Source Methods- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{    NSUInteger row = [indexPath row];    [self.list removeObjectAtIndex:row];    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]                     withRowAnimation:UITableViewRowAnimationAutomatic];}
復(fù)制代碼

這是一個新的方法,第一次使用,當(dāng)用戶要刪除table view中的一行或者進行插入操作時,會觸發(fā)該方法。其中第二個參數(shù)有三個值,分別是:
UITableViewCellEditingStyleNone:什么操作都不執(zhí)行(這個值在上一個例子中使用過)
UITableViewCellEditingStyleDelete:刪除操作
UITableViewCellEditingStyleInsert:插入操作

這個方法里面的具體代碼還是很好理解的,都不多做解釋了。

打開BIDFirstLevelController.m,添加最后的代碼

復(fù)制代碼
#import "BIDFirstLevelController.h"#import "BIDSecondLevelViewController.h"#import "BIDDisclosureButtonController.h"#import "BIDCheckListController.h"#import "BIDRowControlsController.h"#import "BIDMoveMeController.h"#import "BIDDeleteMeController.h"@implementation BIDFirstLevelController@synthesize controllers;- (void)viewDidLoad {    [super viewDidLoad];    self.title = @"First Level";    NSMutableArray *array = [[NSMutableArray alloc] init];        // Disclosure Button    BIDDisclosureButtonController *disclosureButtonController = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];    disclosureButtonController.title = @"Disclosure Buttons";    disclosureButtonController.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];    [array addObject:disclosureButtonController];        // Checklist    BIDCheckListController *checkListController = [[BIDCheckListController alloc] initWithStyle:UITableViewStylePlain];    checkListController.title = @"Check One";    checkListController.rowImage = [UIImage imageNamed:@"checkmarkControllerIcon.png"];    [array addObject:checkListController];        // Row Controls    BIDRowControlsController *rowControlsController = [[BIDRowControlsController alloc] initWithStyle:UITableViewStylePlain];    rowControlsController.title = @"Row Controls";    rowControlsController.rowImage = [UIImage imageNamed:@"rowControlsIcon.png"];    [array addObject:rowControlsController];        // Move Me    BIDMoveMeController *moveMeController = [[BIDMoveMeController alloc] initWithStyle:UITableViewStylePlain];    moveMeController.title = @"Move Me";    moveMeController.rowImage = [UIImage imageNamed:@"moveMeIcon.png"];    [array addObject:moveMeController];        // Delete Me    BIDDeleteMeController *deleteMeController = [[BIDDeleteMeController alloc] initWithStyle:UITableViewStylePlain];    deleteMeController.title = @"Delete Me";    deleteMeController.rowImage = [UIImage imageNamed:@"deleteMeIcon.png"];    [array addObject:deleteMeController];        self.controllers = array;}
復(fù)制代碼

編譯運行

選擇Delete Me進入

點擊右上角的Delete按鈕

點擊左邊的紅圈,出現(xiàn)刪除按鈕

點擊Delete按鈕,刪除改行

再次點擊右上角的Done,還原

另外一種產(chǎn)用的刪除方法,直接在某一行上劃一下,出現(xiàn)Delete按鈕,刪除

4)總結(jié)
好了,這篇三個例子的講解就到此為止,對table view各個方面的屬性進行說明,都是一些很常見的操作,以后在開發(fā)app的時候也一定會使用到這些常用的功能。希望各位能夠看懂,也再次感謝給我留言的每一位朋友,你們是我繼續(xù)寫下去的動力!


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 一级黄色毛片子 | 巨根插入| 嫩草91在线| 91美女啪啪 | 一区二区三区在线观看视频 | 性 毛片| 二区三区四区视频 | 久久精品无码一区二区日韩av | 国产高潮好爽受不了了夜色 | 美女黄污视频 | 国产亚洲福利 | 久久情爱网 | 国产91久久精品 | 欧美日本一区二区 | aa久久| 久久久久国 | 成人做爰高潮片免费视频韩国 | 国内精品久久久久久久影视红豆 | 激情视频在线播放 | 国产免费www | www.54271.com| 56av国产精品久久久久久久 | 91麻豆精品国产91久久久点播时间 | 国产精品久久久毛片 | 免费在线观看毛片视频 | 中文日韩在线视频 | 91综合在线观看 | www.guochanav.com| 色淫影院| 精品999www| 羞羞答答视频 | chinese hd xxxx tube| 精品一区二区中文字幕 | 亚洲精华液久久含羞草 | 12av电影| 日本精品网 | 国产精品视频自拍 | china对白普通话xxxx | av中文在线观看 | 久久精品片| 国产a级网站 |