iOS開發學習之#提醒處理#(1)響應提醒視圖

來源:互聯網
上載者:User

標籤:ios   提醒處理   響應提醒視圖   

在這裡我用到了視圖庫裡的Navigation Controller導航控制器。

提醒操作主要用到了UIAlertviewDelegate協議中的alertView:clickButtonAtIndex:方法實現,其文法形式如下:

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

(UIAlertView *)alertView用來指定警告視圖中包含的按鈕,(NSInteger)buttonIndex用來指定點擊的按鈕的索引

核心代碼如下:

TableViewController.h

#import <UIKit/UIKit.h>@interface TableViewController : UITableViewController<UITableViewDataSource,UITabBarDelegate,UIAlertViewDelegate>{    NSMutableArray *a;}- (IBAction)aa:(id)sender;- (IBAction)bb:(id)sender;@end

TableViewController.m部分程式碼片段

- (IBAction)aa:(id)sender {    UIAlertView *a = [[UIAlertView alloc]initWithTitle:@"編輯" message:@"請選擇項目" delegate:self cancelButtonTitle:@"Canel" otherButtonTitles:@"Add",@"Delete", nil];    [a show];}- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    NSString *b = [alertView buttonTitleAtIndex:buttonIndex];    if ([b isEqualToString:@"Delete"]) {        [self setEditing:YES];    }    if ([b isEqualToString:@"Add"]) {       UIAlertView *a1 = [[UIAlertView alloc]initWithTitle:@"添加" message:@"確定要新增連絡人...嗎" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];        [a1 show];    }}- (IBAction)bb:(id)sender {    [self setEditing:NO];}- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{    if (editingStyle == UITableViewCellEditingStyleDelete) {        [a removeObjectAtIndex:indexPath.row];        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];    }}



iOS開發學習之#提醒處理#(1)響應提醒視圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.