2012-03-18 3 views
0

FirstLevelController 구현 파일에 대해 다음 코드를 작성했지만 Disclosure Buttons 아이콘이 뷰에 표시되지 않습니다. 코드를 확인했지만 무엇이 잘못되었는지 알아낼 수는 없습니다.Disclosure 버튼, 아이콘이 FirstLevelController에 표시되지 않습니다.

FirstLevelController.m :

#import "BiDFirstLevelController.h" 
#import "BidSecondLevelController.h" 
#import "BiDDisclosureButtonController.h" 



@implementation BiDFirstLevelController 
@synthesize controllers; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.title = @"First Level"; 
    NSMutableArray *array = [[NSMutableArray alloc]init]; 


    // Disclosure button 
    BiDDisclosureButtonController *disclosureButtonController = [[BiDDisclosureButtonController alloc]initWithStyle:UITableViewStylePlain]; 
    disclosureButtonController.title = @"Disclosure Buttons"; 
    disclosureButtonController.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"]; 
    [array addObject:disclosureButtonController]; 
} 

- (id)initWithStyle:(UITableViewStyle)style 
{ 
    self = [super initWithStyle:style]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 


- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    self.controllers = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

#pragma mark - Table view data source 

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

    // Return the number of sections. 
    return 0; 
} 

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

    // Return the number of rows in the section. 
    return [self.controllers count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *FirstLevelCell = @"FirstLevelCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstLevelCell]; 
    } 

    // Configure the cell... 
    NSUInteger row = [indexPath row]; 
    BiDSecondLevelController *controller = [controllers objectAtIndex:row]; 
    cell.textLabel.text = controller.title; 
    cell.imageView.image = controller.rowImage; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    return cell; 
} 

#pragma mark - Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSUInteger row = [indexPath row]; 
    BiDSecondLevelController *nextController = [self.controllers objectAtIndex:row]; 
    [self.navigationController pushViewController:nextController animated:YES]; 
} 

@end 
+0

BiDDisclosureButtonController 내에서 rowImage 속성을 유지하거나 소유권을 얻고 싶습니까? – CodaFi

+0

rowImage 속성은 BiDDisclosureButtonController의 슈퍼 클래스 인 BiDSecondLevelController에서 선언되고 합성됩니다. – pdenlinger

+0

이 합성되는 것은 개체를 소유하는 데 너무 멀리 떨어져 있습니다. – CodaFi

답변

0

테이블 뷰는 항상 비어 있어야 의미 numberOfSectionsInTableView: 0을 반환의 구현. 이 메서드에서 0을 반환하는 것이 의미가 없기 때문에 오타라고 생각합니다.

+0

"return [self.controllers count];" 그러나 동일한 문제가 계속 발생합니다. – pdenlinger

관련 문제