2012-05-19 5 views
0

내 뷰 셀에 사용자 지정 uitableviewcell이있는 사용자 지정 UI가 있습니다. 셀이 두 번째로드에 표시되지 않습니다. 즉, 내가이 견해에서 다른 견해로 돌아가서이 견해로 돌아갈 때입니다.사용자 지정 UITableViewCell이 두 번째로드에 나타나지 않습니다.

내보기에서 테이블을로드하는 방법입니다. 내가 다른보기를

AppDelegate_iPhone *appDelegate = [[UIApplication sharedApplication] delegate]; 
AddPestReportStepOne *report = [[AddPestReportStepOne alloc]init]; 
[appDelegate.navCon pushViewController:report animated: YES]; 
[report release]; 

을 이동하는 방법

CropTableViewController *cropTblViewCon = [[CropTableViewController alloc]init]; 
self.cropTableViewController = cropTblViewCon; 
cropTableViewController.view.frame = cropTblView.frame; 
[cropTblView removeFromSuperview]; 
[self.view addSubview:cropTableViewController.view]; 
self.cropTblView = cropTableViewController.tableView; 

이이 내가 내 사용자 정의 테이블보기에서 내 테이블 셀을로드하는 방법입니다.

static NSString *CellIdentifier = @"CustomCropCell";  
CustomCropCell *cell = (CustomCropCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
tableView.scrollEnabled = NO; 
// tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 
    NSArray *topLevelObjects = [[NSBundle mainBundle] 
           loadNibNamed:@"CustomCropCell" owner:nil options:nil]; 

    for (id currentObject in topLevelObjects){ 

     if ([currentObject isKindOfClass:[UITableViewCell class]]) { 
      cell = (CustomCropCell *) currentObject; 
      break; 
     } 
    } 
} 
//if (counter<6) { 

CropEntity *crop = [[CropEntity alloc] init]; 
crop=[ cropList objectAtIndex:counter]; 

NSString *imgStr = [NSString stringWithFormat:@"%@%@%@",domainName,cropImagePath, [crop cropImage]];  
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgStr]]]; 
CGSize size = CGSizeMake(80, 80); 
[cell setBackgroundColor: [UIColor clearColor]]; 
image = [Utilities scale:image toSize:size ]; 
[cell.columnOne setTag: [[crop cropId] integerValue] ]; 
[cell.columnOne setTitle:[crop cropName] forState:UIControlStateNormal]; 
[cell.columnOne setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
[cell.columnOne setTitleEdgeInsets:UIEdgeInsetsMake(0.0, -image.size.width, -75.0, 0.0)]; // Left inset is the negative of image width. counter = counter+ 1; 
[cell.columnOne setImage:image forState:UIControlStateNormal]; 
[cell.columnOne setImageEdgeInsets:UIEdgeInsetsMake(-15.0, 0.0, 0.0, -cell.columnOne.titleLabel.bounds.size.width)]; // Right inset is the negative of text bounds width. 
[cell.columnOne setBackgroundColor: [UIColor clearColor]]; 
counter = counter + 1; 

행이 제거되지 않은 것으로 보입니다. 내 cellforrowat indexpath 증가 계속 ...

답변

0

좋아, 나는 당신이 ViewController에 UITableView를 추가하려는 가정합니다. 다음은이 단계는 다음과 같습니다

(1) 코드 또는 인터페이스 빌더에 의해 여부,의 UIViewController를 만들 수 있습니다

(2) jQuery과 작성하고있는 UIViewController에 추가를

UITableView *tableView = [[UITableView alloc] 
          initWithFrame:CGRectMake(0, 0, 320, 440) 
          style:UITableViewStylePlain]; 

// Set up the tableView delegate and datasource 

[self.view addSubview:tableView]; 

[tableView release]; 

UIViewController에 tableView를 추가하는 이유가 있는지 확신합니다. 추가 UITableViewController가있는 이유가 없습니다 .UITableViewController를 사용하지 않고 UITableView를 설정하면 UITableView를 설정하십시오.

또한 염두에 두십시오. 당신이 어디에서 creat tableView에. 예를 들어, init 또는 viewDidLoad에서 UINavigationController를 사용하여 만들고 UINavigationController에서 뒤로 버튼을 누르면 ViewDidLoad 또는 init이 호출되지 않습니다. 직접 시도해보십시오. NSLog 문을 테스트 해보십시오.

따라서 viewDidAppear 또는 [tableView reloadData]를 사용하십시오.

편집 :

당신이 그것을 슈퍼 뷰 (이해가되지 않습니다)이다에서 당신이 jQuery과를 제거하려면 UITableViewContoller을 만든 다음 인 self.view하는 UITableViewControllers 뷰 (jQuery과)를 추가 코드에 대한 생각 UIViewController 추측하고있어. 확실히 이것은 당신이하려는 것을 할 수 없습니다.

Apple의 View Programming 가이드를 읽고 UIViewController와 Views를 더 잘 이해할 것을 권합니다.

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html

관련 문제