iPhone应用程序无法在设备上工作

时间:2011-08-10 10:14:55

标签: iphone objective-c

我有iPhone它在模拟器上工作正常但不在设备上它首先工作但现在它不工作

还提供以下警告

WARNING: Using legacy cell layout due to delegate implementation of   tableView:accessoryTypeForRowWithIndexPath: in <CategoriesList: 0x497b000>.  Please remove your implementation of this method and set the cell properties accessoryType and/or editingAccessoryType to move to the new cell layout behavior.  This method will no longer be called in a future release.

这是我的应用的第一个视图表视图

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];    
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 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;
Book*aBook=[appDelegate.books objectAtIndex:indexPath.row];

NSString*celltext=aBook.name;
cell.textLabel.textColor=[UIColor blackColor];
cell.textLabel.text=celltext;
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.backgroundColor=[UIColor clearColor];
self.tableView.backgroundColor=[UIColor clearColor];
self.title=aBook.name;

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//cell.textLabel.backgroundColor=[UIColor clearColor];
//UIImage* theImage = [UIImage imageNamed:@"cell1.png"];
//cell.image = theImage;
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];  
        }

 }

1 个答案:

答案 0 :(得分:0)

你没有告诉我们它不工作的原因吗?你收到任何错误或崩溃吗? 与您的警告相关:

  

标识为已弃用的accessoryTypeForRowWithIndexPath方法已被取代,将来可能不受支持。

     

因此,在配置表格视图单元格时,您需要使用UITableViewCell类的附件视图和附件类型属性(对于正常模式和编辑模式)。