码迷,mamicode.com
首页 > 其他好文 > 详细

MTLableAlertDemo

时间:2014-10-27 14:14:54      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   os   ar   for   sp   

效果图:

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

MTLableAlertDemo

标签:style   blog   http   io   color   os   ar   for   sp   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4053974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!