2014-02-16 6 views
0

저는 테이블 뷰 컨트롤러가 아닌 일반 뷰 컨트롤러가 있고 뷰에는 테이블 뷰가 있습니다. 내 테이블 뷰 셀은 사용자 정의이며 방금 스토리 보드를 통해 만들었지 만 코드에서 아무 것도하지 않았지만 응용 프로그램을 실행할 때 tableview는 비어 있습니다. tho가 나에게 일어나고있는 이유에 관한 어떤 생각? 여기에 다른 것들을 보았습니다. 그러나이 모든 다른 시나리오는 NSArray를 사용하여 코드에서 tableview를 채우는 사람과 관련이 있습니다.하지만 광산은 관례이므로 나는 그렇게하지 않습니다. 어떤 도움을 주셔서 감사합니다. 그리고이 복제물을 표시하기 전에 실제로 이것을 읽어주십시오. 다음과 같이 내 코드는 다음과 같습니다사용자 정의 테이블보기 셀이 비어 있습니다.

@interface TTViewController() 
{ 
    NSArray *messageComponents; 
} 

@end 

@implementation TTViewController 
@synthesize dateTimePicker, messageSetupTableView; 


    - (void)viewDidLoad 
    { 
     [super viewDidLoad]; 
     // Do any additional setup after loading the view, typically from a nib. 

     self.title = @"Message Setup"; 

     messageComponents = [[NSArray alloc] initWithObjects:@"Recipient",@"Message", @"Date",@"haha", nil]; 


     messageSetupTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; 
     messageSetupTableView.alpha = 0.9; 

    } 
    #pragma mark - 
    #pragma mark Table view data source 

    -(NSInteger) numberOfSectionsInTableView:(UITableView *) tableView{ 

     return [messageComponents count]; 
    } 

    -(NSInteger)tableView:(UITableView *) tableVew numberOfRowsInSection:(NSInteger)section{ 

     return 1; 
    } 

    // Customize the appearance of table view cells. 
    - (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]; 
      if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
      } 
     } 

     // Configure the cell. 

     cell.textLabel.text = [messageComponents objectAtIndex:indexPath.row]; 
     cell.imageView.image = [UIImage imageNamed:[messageComponents objectAtIndex:indexPath.row]]; 

     cell.backgroundColor = [UIColor redColor]; 
     cell.textLabel.textColor = [UIColor whiteColor]; 

     UIColor *selectedColor = [UIColor blueColor]; 
     UIView *myBackgroundColor = [[UIView alloc] init]; 
     [myBackgroundColor setBackgroundColor:selectedColor]; 

     [cell setSelectedBackgroundView:myBackgroundColor]; 

     return cell; 

가 내 테이블 뷰가 다른의 date picker in one section, 다른의 textviewa button and a few text fields 갖고 싶어. 감사합니다

+0

지금까지 시도한 코드를 붙여 넣으세요. – Pawan

+0

방금 ​​내 질문에 몇 가지 코드를 게시했습니다. –

+0

[quickdialog] (https://www.cocoacontrols.com/controls/quickdialog), 언급 한 것과 같은 요구 사항에 대한 아주 좋은 예입니다. – cjd

답변

0

제안의 몇 :

  1. 먼저 UITableView대표데이터 소스 매핑되어 있는지 확인 여부를 하나 IB 또는 programmatically에서.

  2. cellForRowAtIndexPath 대리자 기능에 중단 점을 넣고이 함수가 제공되는지 확인하고이 함수를 사용하여 사용자 지정 셀을 만들 었는지 확인하십시오.

  3. 더블 비슷한 사용하여이 tableView 적어도 하나 개의 행이 확인 :

    - (NSInteger)numberOfRowsInSection:(NSInteger)section 
    { 
        return 5; // for test pass value 5 so tableView should aware to display 5 rows. 
    } 
    

가 도움이 희망을!

+1

함수 시그니처에는 실제로 매개 변수 이름이 포함되어 있지 않습니다. tableView : numberOfRowsInSection : parts가 일치하는 한 aTableView, tableView, table 등을 사용할 수 있습니다. –

+0

맞습니다. 실제로 변경된 부분이 실제로 인식되는 부분 대신에 param 이름임을 알지 못합니다. 그 이유는 우리가 @selector (function1 : withsecondArgument :)와 같은 이유는 param 이름을 언급하는 대신 언급합니다. – NeverHopeless

관련 문제