Unable to Populate TableView In PopOverController - Objective C

前端 未结 4 506
一生所求
一生所求 2021-01-26 11:59

I have a UIButton called as UploadButton. I am using the following lines of code which takes care of the action which should happen on clicking it ::

相关标签:
4条回答
  • 2021-01-26 12:33

    Use the following code in cellForRowAtIndexPath:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        // Configure the cell...
    
        if( cell == nil )
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
    
        NSString *key1 = [keys1 objectAtIndex:indexPath.row];
        cell.textLabel.text = key1;
    
        return cell;
    
    }
    

    I think this may helpful for you.

    0 讨论(0)
  • 2021-01-26 12:48

    That error means that you're passing an invalid argument when you're assigning a value to keys1, self.keys1 = .... If you're, e.g., passing a NSMutableArray to an NSDictionary property, you'll get that error.

    0 讨论(0)
  • 2021-01-26 12:54

    The problem is the following line:

    self.keys1 = [NSMutableArray array];
    

    Your UploadSpaceTableViewController has no method setKeys / no property keys.

    Edit for the 2nd error message:

    UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:

    This means that you should implement the UITableViewDataSource method tableView:cellForRowAtIndexPath:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        //configure your cell here
    
        return myCongiuredTableViewCell;
    }
    
    0 讨论(0)
  • Have you allocated your cell i think by your code it will return nill

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
     static NSString *CellIdentifier = @"Cell";
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
     if(cell == nill){
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];  
    }     
     // Configure the cell...
    
     NSString *key1 = [keys1 objectAtIndex:indexPath.row];
     cell.textLabel.text = key1;
    
     return cell;
    }
    

    may this will help you...

    0 讨论(0)
提交回复
热议问题