سؤال

أقوم ببناء طاولة مقطوعة ، وهو يظهر مع ما يبدو أنه قسم أعلى القسم. يمكنك أن ترى على الصورة أن هناك خط أبيض تحت كل قسم.

الصورة

فيما يلي الرمز الذي يجب أن أبنيه على الجدول:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [alertList count];
}


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



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier;

 if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
 {
  CellIdentifier = @"CellLandscape";
 }
 else
 {
  CellIdentifier = @"Cell";
 }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

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

  //cell.contentView.backgroundColor = [UIColor blackColor];

  CGRect frame;

  if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
  {
   frame.origin.x = 370;
   //titleFrame.size.width = 320;
  }
  else
  {
   frame.origin.x = 220;
   //titleFrame.size.width = 220;
  }

  frame.origin.y = 5;
  frame.size.height = 15;
  frame.size.width = 74;

  UILabel *instLabel = [[UILabel alloc] initWithFrame:frame];
  instLabel.tag = 1;
  [cell.contentView addSubview:instLabel];
  [instLabel release];
    }


 // Configure the cell.
 Alert *p = [alertList objectAtIndex:indexPath.section];

 UILabel *instLabel = (UILabel *) [cell.contentView viewWithTag:1];
 instLabel.text = [p docDate];
 instLabel.textColor = [UIColor blackColor];
 [instLabel setFont:[UIFont fontWithName:@"Arial" size:12]];

 NSString *path;

 if ([[p subscription] isEqual:@"Y"])
 {
  path = [[NSBundle mainBundle] pathForResource:@"watchlist_on" ofType:@"png"];
 }
 else
 {
  path = [[NSBundle mainBundle] pathForResource:@"watchlist_off" ofType:@"png"];
 }

 //NSLog(@"%@", path);

 cell.textLabel.textColor = [UIColor colorWithRed:.847 green:0 blue: 0 alpha: 1];
 [cell.textLabel setFont:[UIFont boldSystemFontOfSize:13]];
 cell.textLabel.text = [[NSString alloc] initWithFormat:@"%@", [p Name]];

 cell.detailTextLabel.textColor = [UIColor blackColor];
 [cell.detailTextLabel setFont:[UIFont fontWithName:@"Arial" size: 10]];
 cell.detailTextLabel.text = [p docTitle];

 cell.detailTextLabel.textColor = [UIColor blackColor];
 [cell.detailTextLabel setFont:[UIFont fontWithName:@"Arial" size: 10]];
 //cell.detailTextLabel.text = [p docDate];

 //cell.imageView.image = [UIImage imageWithContentsOfFile:path];
 cell.imageView.userInteractionEnabled = YES;
 cell.imageView.userInteractionEnabled = YES;

 //cell.imageView.image = [UIImage imageWithContentsOfFile:path];

 ///    [cell addSubview:imgView];

 //cell.textLabel.text = [[NSString alloc] initWithFormat:@"%@, %@ G: %@\nDOB: %@ Inst: %@", [p lastName], [p firstName], [p gender], 
 //        [p birthDate], [p inst]];

 cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

 //only 1 alert at a time

 //make doc list from alert object
 Document *documentList1 = [[Document alloc] init];
 self.documentList = documentList1;
 [documentList1 setTitle:[p docTitle]];
 [documentList1 setUniqueId:[p uniqueId]];
 [documentList1 setDate:[p docDate]];
 [documentList1 setRepoOID:[p repoOid]];
 [documentArray addObject:documentList];

    return cell;
}
هل كانت مفيدة؟

المحلول

قم بتغيير نمط فاصل عرض الجدول إلى سطر واحد أو لا شيء - ربما يكون لديك على خط واحد محفور.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top