2013-01-14 9 views
0

나는 내 UIViewController에서 UITableView가 있지만 문제가 발생하지만 UITableView에 내용을 추가하고 데이터를 다시로드 할 때 아무 일도 발생하지 않습니다.Xcode UIViewController의 UITableView 내용을 표시하지 않습니다

내 UIViewController에 :

@interface WPCreateViewController : UIViewController<UITableViewDelegate, UITableViewDataSource, UIActionSheetDelegate> { 
    .... 
    @property (strong, nonatomic) IBOutlet UITableView *tableViewEntities; 
    @property (strong, nonatomic) NSMutableArray *entities; 
    .... 
    - (IBAction)cancel:(id)sender; 
    - (IBAction)save:(id)sender; 
    - (IBAction)addEntities:(id)sender; 
    - (IBAction)deleteEntities:(id)sender; 
} 

그리고 구현은 같다 :

@implementation WPCreateViewController 

- (void)viewDidLoad{ 
    [super viewDidLoad]; 
    .... 
    [self.tableViewEntities setAllowsMultipleSelectionDuringEditing:YES]; 
    [self.entities setArray:[[NSMutableArray alloc] init]]; 

    .... 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [self.entities count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSString *cellID = @"WPEntityCell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID]; 
    } 

    cell.textLabel.text = [[self.entities objectAtIndex:indexPath.row] name]; 
    cell.detailTextLabel.text = [[self.entities objectAtIndex:indexPath.row] description]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

    return cell; 
} 

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

} 

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

} 

내가 뭔가 아무것도 내가 버튼과 연결이 방법을 가지고 말한대로 발생하지 않습니다 추가하려고하면

- (IBAction)addEntities:(id)sender { 
    Entity *temp = [[Entity alloc] init]; 
    temp.name = @"Test"; 
    temp.description = @"TestTest"; 

    [self.entities addObject:temp]; 

    [self.tableViewEntities reloadData]; 
} 

그런데 모든 연결이 올바르게 설정되었으므로 uitableview가 적합하지 않은 이유는 무엇입니까? 뭐라구?

답변

1

보기 컨트롤러를 위임자로, dataSource를 tableView로 설정하십시오.

+0

코드 작성자가이 인터페이스 빌더에서 이미 수행했습니다. 코드에서 수행하는 경우에도 마찬가지입니다. – user1882812

+1

numberOfSectionsInTableView : 또는 numberOfRowsInSection : 메소드에 중단 점을 설정하면 충돌이 발생합니까? – Lance