Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add the horizontal line at the specific position and the label at the position and it will look like this.</p> <p>Create a tableview and than in <code>cellForRowAtIndexPath</code> method add this code..</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *SimpleTableIdentifier; UITableViewCell * cell; SimpleTableIdentifier = @"SimpleTableIdentifier"; cell = [tableView dequeueReusableCellWithIdentifier: nil]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier]; UILabel * numLbl = [[UILabel alloc] initWithFrame:CGRectMake(0,5,33,30)]; numLbl.text = @"1"; [numLbl setFont:[UIFont fontWithName:@"Helvetica" size:10.0]]; numLbl.backgroundColor = [UIColor clearColor]; [cell addSubview:numLbl]; UILabel * nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(30,5,50,30)]; nameLbl.text = @"john%Lakeview"; [nameLbl setFont:[UIFont fontWithName:@"Helvetica" size:10.0]]; nameLbl.backgroundColor = [UIColor clearColor]; [cell addSubview:nameLbl]; //create a hoizontal separator in cell to display it like column UIView* hSeparatorview1 = [[UIView alloc] initWithFrame:CGRectMake(25, 0, 1, 30)]; hSeparatorview1.backgroundColor = [UIColor blackColor]; hSeparatorview1.tag = 1; [cell addSubview:hSeparatorview1]; UIView* hSeparatorview2 = [[UIView alloc] initWithFrame:CGRectMake(85, 0, 1, 30)]; hSeparatorview2.backgroundColor = [UIColor blackColor]; hSeparatorview2.tag = 2; [cell addSubview:hSeparatorview2]; } return cell; } //this method is used to set the hight of the tableview cell - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; { return 30; } </code></pre> <p>I have created it for only two label and two horizontal view but you can create as many as you like. </p> <p>And yes dot forget to place this code in <code>didSelectRowAtIndexPath</code> otherwise horizontal view will disappear when user click the cell. </p> <pre><code>- (void)tableView:(UITableView *)atableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //get the cell which is selected UITableViewCell *selectedCell = [atableView cellForRowAtIndexPath:indexPath]; //set cell horizontal saparator view color of selected cell bcoz when cell selected all view color is gone UIView *hSeparatorview1=[selectedCell viewWithTag:1]; hSeparatorview1.backgroundColor = [UIColor blackColor]; UIView *hSeparatorview2=[selectedCell viewWithTag:2]; hSeparatorview2.backgroundColor = [UIColor blackColor]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload