IOS AlterView的使用(IOS8.0以前使用)

來源:互聯網
上載者:User

標籤:round   pat   彈框   field   loaddata   tle   return   名稱   .text   

 

 

#pragma mark - 代理方法- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    // 1.取得被點擊這行對應的模型    MJHero *hero = self.heros[indexPath.row];        // 彈框    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"資料展示" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];        // 設定對話方塊的類型    alert.alertViewStyle = UIAlertViewStylePlainTextInput;        // 取得唯一的那個文字框,顯示英雄的名稱    [alert textFieldAtIndex:0].text = hero.name;        [alert show];        // 綁定行號到alertView上    alert.tag = indexPath.row;}#pragma mark - alertView的代理方法/** *  點擊了alertView上面的按鈕就會調用這個方法 * *  @param buttonIndex 按鈕的索引,從0開始 */- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    if (buttonIndex == 0) return;        // 按鈕的索引肯定不是0        // 1.取得文字框最後的文字    NSString *name = [alertView textFieldAtIndex:0].text;//    int row = alertView.tag;//    NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:0];//    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:path];//    cell.textLabel.text = name;        // 2.修改模型資料    int row = alertView.tag;    MJHero *hero = self.heros[row];    hero.name = name;        // 3.告訴tableView重新載入模型資料    // reloadData : tableView會向資料來源重新請求資料    // 重新調用資料來源的相應方法取得資料    // 重新調用資料來源的tableView:numberOfRowsInSection:獲得行數    // 重新調用資料來源的tableView:cellForRowAtIndexPath:得知每一行顯示怎樣的cell    // 全部重新整理//    [self.tableView reloadData];        // 局部重新整理    NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:0];    [self.tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationBottom];}

 

IOS AlterView的使用(IOS8.0以前使用)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.