以下のコードで構築した 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];
}
ループでは、For
「[STVars myMutableArray]」が表示されます。これは、質問配列の格納に使用されるシングルトン メソッドです。
私の問題は、すべての質問のタイトルをロードできるようにする必要がある UITableView を持つ UIPopOverController があるという事実にあります.....ex(@"Question 1", @"Question 2")。これらは、UIPopOverController の UITableView のデータソースとして設定する必要があります。
同様に、質問配列を初期化するクラスには、UIPopOverController からクリックされた質問の質問配列からすべての戦略を取得する必要がある UICollectionView があります。
これは、データを持つシングルトン配列にアクセスする UIPopOverController です。配列をアタッチしてセルを読み込もうとすると、「SIGABRT」エラーが発生します.....(それは嫌いです。)
- (id)initWithStyle:(UITableViewStyle)style
{
if ([super initWithStyle:style] != nil) {
//Log test
NSLog(@"QuestionList init method from STVars: %@",[STVars myMutableArray]);
QuestionsList = [STVars myMutableArray];
最初に 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;
}
これらのセルを取得して、配列からの質問を入力できないようです。なぜそれが表示されないのかについての簡単な説明は本当に素晴らしいでしょう. 私は数日間まっすぐに開発してきましたが、それは単純なものかもしれないと思いますが、それを捕まえることはできません....どんな助けも大歓迎です!