Ipad 将数据阵列到UITableView和UICollectionView

Ipad 将数据阵列到UITableView和UICollectionView,ipad,uitableview,nsmutablearray,singleton,uipopovercontroller,Ipad,Uitableview,Nsmutablearray,Singleton,Uipopovercontroller,我用下面的代码构建了一个NSMutableArray //Question Array Setup and Alloc stratToolsDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:countButton,@"count",camerButton,@"camera",videoButton,@"video",textButton,@"text",probeButton,@"probe", nil]; st

我用下面的代码构建了一个NSMutableArray

//Question Array Setup and Alloc
    stratToolsDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:countButton,@"count",camerButton,@"camera",videoButton,@"video",textButton,@"text",probeButton,@"probe", nil];
    stratTools = [[NSMutableArray alloc] initWithObjects:@"Tools",stratToolsDict, nil];
    stratObjectsDict = [[NSMutableDictionary alloc]initWithObjectsAndKeys:stratTools,@"Strat1",stratTools,@"Strat2",stratTools,@"Strat3",stratTools,@"Strat4", nil];
    stratObjects = [[NSMutableArray alloc]initWithObjects:@"Strategies:",stratObjectsDict,nil];
    QuestionDict = [[NSMutableDictionary alloc]initWithObjectsAndKeys:stratObjects,@"Question 1?",stratObjects,@"Question 2?",stratObjects,@"Question 3?",stratObjects,@"Question 4?",stratObjects,@"Question 5?", nil];


    //add strategys to questions
    for (int i = 0; i < 1; i++) {
        //Send Var to STVar
        [[STVars myMutableArray]addObject:QuestionDict];
    }
您可以看到,我首先检查NSLog,以确保数据位于Singleton类的数组中。然后我将该数组分配给另一个NSMutableArray*QuestionsList

当我将其分配给UITableView时,它从未显示

调整UIPopOvercontroller的大小:

//Make row selections persist.
        self.clearsSelectionOnViewWillAppear = NO;

        //Calculate how tall the view should be by multiplying
        //the individual row height by the total number of rows.
        NSInteger rowsCount = [QuestionsList count];
        NSInteger singleRowHeight = [self.tableView.delegate tableView:self.tableView
                                               heightForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
        NSInteger totalRowsHeight = rowsCount * singleRowHeight;

        //Calculate how wide the view should be by finding how
        //wide each string is expected to be
        CGFloat largestLabelWidth = 0;
        for (NSString *questionName in QuestionsList) {
            //Checks size of text using the default font for UITableViewCell's textLabel.
            CGSize labelSize = [questionName sizeWithFont:[UIFont boldSystemFontOfSize:20.0f]];
            if (labelSize.width > largestLabelWidth) {
                largestLabelWidth = labelSize.width;
            }
        }

        //Add a little padding to the width
        CGFloat popoverWidth = largestLabelWidth + 100;

        //Set the property to tell the popover container how big this view will be.
        self.contentSizeForViewInPopover = CGSizeMake(popoverWidth, totalRowsHeight);
表格单元格代码:

- (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];
    }

    // Configure the cell...
    cell.textLabel.text = [QuestionsList objectAtIndex:indexPath.row];

    return cell;
}
我似乎无法让这些单元格填充数组中的任何问题。 一个很好的简单解释,解释为什么它可能不会出现,这将是非常好的。
我已经连续开发了几天,我认为这可能是一个简单的东西,但无法赶上它…任何帮助都是非常感谢的

看起来您需要初始化问题列表,我知道您可以像这样分配数据,并且在表实际查找计数或尝试创建单元格之前不会出现错误。Try QuestionsList=[NSMutableArray alloc]initWithObjects:[STVars myMutableArray],nil]@雷赞德,我试过了,但发现了西格伯特的错误?如果我打开聊天室,你能帮我解决这个问题吗?@rezand
- (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];
    }

    // Configure the cell...
    cell.textLabel.text = [QuestionsList objectAtIndex:indexPath.row];

    return cell;
}