2013-11-26 37 views
0

我在Xcode中得到相同的錯誤,並無法找出爲什麼(我的壞) 我試圖檢索已保存的數據,使用的uitexfield代碼低於 該部分是保存從視圖中檢索數據到故事板中的UITableViewCell

- (IBAction)saveCourseDetail:(id)sender 
{ 
    NSMutableDictionary *courseDictionary=[NSMutableDictionary new]; 
    [courseDictionary setObject:courseName.text forKey:@"courseName"]; 
    [courseDictionary setObject:courseDescription.text forKey:@"courseDescription"]; 
    [courseDictionary setObject:classRoom.text forKey:@"classRoom"]; 
    [courseDictionary setObject:teacherName.text forKey:@"teacherName"]; 
    [courseDictionary setObject:buildingName.text forKey:@"buildingName"]; 

    NSUserDefaults *savedData=[NSUserDefaults standardUserDefaults]; 
    [savedData setObject:courseDictionary forKey:@"courseDictionary"]; 
    [savedData synchronize]; 
// [self.delegate reloadTableData]; 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"CourseAddedNotification" object:nil]; 
    [self.navigationController popViewControllerAnimated:YES]; 
} 
#pragma mark Course Tableview 


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     NSString *string = [_dataArray objectAtIndex:indexPath.row]; 

     NSString *CellIdentifier = @"Cell"; 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     if(cell==nil) 
     { 
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     } 
     cell.textLabel.text=string; 

     return cell; 
    } 
    and the tableview that i'm trying to get the saved course details 



#pragma mark - Table View Delegate - 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 10; 
} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    CourseCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 
    if (!cell) { 
     cell = [[CourseCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 
    } 
    return cell; 
} 

,但我不斷收到同樣的錯誤,而─ 2013年11月26日14:43:19.496 SidebarDemo [1170:70B] *在斷言失敗 - [UITableView的dequeueReusableCellWithIdentifier:forIndexPath:]/SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:5261 2013-11-26 14:43:19.500 SidebarDemo [1170:70b] *終止應用程序,由於未捕獲的異常'NSInternalInconsistencyException',原因:'無法使用標識符單元出列單元格 - 必須爲標識符註冊一個筆尖或類或連接故事板中的原型單元格'

任何人都可以幫助我?

+1

你有帶小區的IDENTIFER在你的故事板的原型細胞? – bobnoble

回答

0

您必須在故事板中的attributinspector 4.tab中設置單元格標識符。標識符必須與源代碼中的標識符相同(此處爲「單元格」)。

0

您必須使用

static NSString *CellIdentifier = @"messageCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

不要使用

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

蘋果文檔:

重要

必須使用registerNib註冊類或筆尖文件:forCellReuseIdentifier:或registerClass:forCellReuseIdentifier:在調用此方法之前的方法的ThOD。

0

添加identifieruitableviewCellstoryboard,給命名爲「細胞」一樣的,你正在使用的cellForRowAtIndexPath:方法

相關問題