How do you use BlockTableAlertView? #53

Closed
sabernar opened this Issue Jun 23, 2013 · 4 comments

Projects

None yet

3 participants

@sabernar

There is no example, and the class is not very intuitive. Can you post an example?

@barrettj
Collaborator

Implement the following like they were your table data source:

@property (readwrite,copy)  TableAlertIndexBlock didSelectRow;
@property (readwrite,copy)  TableAlertCellSourceBlock cellForRow;
@property (readwrite,copy)  TableAlertNumberOfRowsBlock numberOfRowsInTableAlert;
@barrettj barrettj closed this Jun 24, 2013
@sabernar

Can you provide an example of the TableAlertCellSourceBlock cellForRow method?

@jmyrose
jmyrose commented Jul 18, 2013

Here's the code I used that worked:

BlockTableAlertView *listView = [[BlockTableAlertView alloc] initWithTitle:@"Available Boards" message:@"Add      webpage to board:"];
listView.type = BlockTableAlertTypeSingleSelect;
listView.numberOfRowsInTableAlert = ^(BlockTableAlertView* alertView){
    return [boardsArray count];
};
listView.cellForRow = ^(BlockTableAlertView* alertView, NSInteger row){
    static NSString *CellIdentifier = @"CellIdentifier";

    UITableViewCell *cell = [alertView.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    // Set the data for this cell:
    NEBoardsListItem *board = [boardsArray objectAtIndex:row];
    cell.textLabel.text = board.title;

    return cell;
};
 listView.didSelectRow = ^(BlockTableAlertView* alertView, NSInteger row){
    NSLog(@"Selected row: %d", row);
};
@jmyrose
jmyrose commented Jul 19, 2013

Also, just added a pull request with a demo of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment