2011-08-25 71 views
0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

Book1*aBook; 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
    UIImageView* img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cell1.png"]]; 
    [cell setBackgroundView:img]; 
    [img release]; 
} 



UIImage *image = [UIImage imageNamed:@"arrow.png"] ; 
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height); 
button.frame = frame; 
[button setBackgroundImage:image forState:UIControlStateNormal]; 

[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 
button.backgroundColor = [UIColor clearColor]; 


cell.accessoryView = button; 






if(indexPath.section == 0) 
{ 
    aBook=[appDelegate.books1 objectAtIndex:indexPath.row]; 
} 
else if(indexPath.section == 1) 
{ 
    aBook=[appDelegate.books2 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 2) 
{ 
    aBook=[appDelegate.books3 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 3) 
{ 
    aBook=[appDelegate.books4 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 4) 
{ 
    aBook=[appDelegate.books5 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 5) 
{ 
    aBook=[appDelegate.books6 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 6) 
{ 
    aBook=[appDelegate.books7 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 7) 
{ 
    aBook=[appDelegate.books8 objectAtIndex:indexPath.row]; 

} 

else if(indexPath.section == 8) 
{ 
    aBook=[appDelegate.books9 objectAtIndex:indexPath.row]; 

} 
else if(indexPath.section == 9) 
{ 
    aBook=[appDelegate.books10 objectAtIndex:indexPath.row]; 

} 

    cell.text = aBook.municipality; 
    cell.detailTextLabel.text=aBook.title; 


    eventId = [NSString stringWithFormat:@"%d", aBook.eventId]; 
    affectedDate = [NSString stringWithFormat:@"%d", aBook.affecteddate]; 


    cell.textLabel.backgroundColor=[UIColor clearColor]; 
    cell.backgroundColor=[UIColor clearColor]; 
    self.tableView.backgroundColor=[UIColor clearColor]; 


cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 


return cell; 

}如何通过节表视图中的数据的详细视图

  - (void)checkButtonTapped:(id)sender event:(id)event 
    { 
     NSSet *touches = [event allTouches]; 
    UITouch *touch = [touches anyObject]; 
    CGPoint currentTouchPosition = [touch locationInView:self.tableView]; 
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition]; 
     if (indexPath != nil) 
    { 
    [self tableView: self.tableView accessoryButtonTappedForRowWithIndexPath: indexPath]; 


    } 
    } 




     - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

NSString*myid=eventId; 
NSString*date=affectedDate; 


DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
dvController.eventId=myid; 
dvController.affectedDate=date; 

[self.navigationController pushViewController:dvController animated:YES]; 
[dvController release]; 






} 

我使用这种方式将数据发送到详细信息视图控制器,但它给了例外

+0

在您尝试使用'自presentmodalviewcontroller'这样的情况下,同时显示detailViewcontroller ... – DShah

+0

有你设置属性,并以detailviewcontroller合成的事件ID和affectedid正常吗? –

+0

是的,我已经syntesize以及事件ID工作BYT affecteddate给我用同样的方式两个 – ali

回答

0

尝试检查接口的笔尖建设者的错误/警告 - 也许你有错误的东西。

相关问题