MTLableAlertDemo

时间:2014-10-27 14:14:54   收藏:0   阅读:152

效果图:

bubuko.com,布布扣

工程目录:

bubuko.com,布布扣

此代码需要加第三方库,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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!