开发者

How to implement this kind of style table

How to implement this kind of style table

There is table inside cell and every tiny cell can be clicked to trigge开发者_如何学编程r another page.


This looks like Twitter app.

I think, these methods may help you:

  • Create a UIView with 2 Label for Number and Text; name it labelView
  • Make a button [UIButton alloc] buttonWithType: UIButtonTypeCustom]
  • Add your lableView as a subview of this button.
  • Make a cell with 2 button: side by side
  • To make the seperator: #import <QuartzCore/QuartzCore.h>, then

    labelView.layer.borderSize = 1;

    labelView.layer.borderColor = [UIColor grayColor].CGColor;

  • Manually move your buttons to appropriate position. You may want to use: cell.contentView.clipsToBounds = YES also

Hope this help.


- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    NSString* cellIdentifier = @"cellIdentifier";   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    UIButton* tempBtn1;     
    UIButton* tempBtn2;     

    if(cell == nil)
    {
        cell = (UITableViewCell*) [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];

        tempBtn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        tempBtn1.tag = 123;
        tempBtn1.frame = CGRectMake(0, 0, 160, 44);
        [tempBtn1 setTitle:@"firstBtn" forState:UIControlStateNormal];
        [cell.contentView addSubview:tempBtn1];

        tempBtn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        tempBtn2.tag = 234;
        tempBtn2.frame = CGRectMake(160, 0, 160, 44);
        [tempBtn2 setTitle:@"secondBtn" forState:UIControlStateNormal];
        [cell.contentView addSubview:tempBtn2];     
    }
    else {
        tempBtn1 = (UIButton*)[cell.contentView viewWithTag:123];       
        [cell.contentView addSubview:tempBtn1];         
        tempBtn2 = (UIButton*)[cell.contentView viewWithTag:234];       
        [cell.contentView addSubview:tempBtn2];     
    }

    return cell; 
}


Create a UIView subclass. This will represent one item (1/2 of the cell content). Add two of these in each cell. Detect touches in this UIView subclass and push new ViewController when you get the touch events.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜