首页 > 代码库 > MTLableAlertDemo

MTLableAlertDemo

效果图:

工程目录:

此代码需要加第三方库,MLTableAlert.

 

RootViewController.m

//点击任何处,出现提示框-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    [self showTableAlert];}-(void)showTableAlert{    // create the alert    self.alert = [MLTableAlert tableAlertWithTitle:@"Choose an option..." cancelButtonTitle:@"Cancel" numberOfRows:^NSInteger (NSInteger section)                  {                      //tableView row的数量                      return 5;                  }                 andCells:^UITableViewCell* (MLTableAlert *anAlert, NSIndexPath *indexPath)                  {                      static NSString *CellIdentifier = @"CellIdentifier";                      UITableViewCell *cell = [anAlert.table dequeueReusableCellWithIdentifier:CellIdentifier];                      if (cell == nil)                          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];                                            cell.textLabel.text = [NSString stringWithFormat:@"Section %d Row %d", indexPath.section, indexPath.row];                                            return cell;                  }];        self.alert.height = 350;    [self.alert configureSelectionBlock:^(NSIndexPath *selectedIndex){        NSLog(@"---%d--%d--",selectedIndex.section,selectedIndex.row);    } andCompletionBlock:^{        NSLog(@"Cancel Button Pressed\nNo Cells Selected");    }];        [self.alert show];}

 

源代码地址:http://url.cn/NRRHBf

MTLableAlertDemo