2017-10-24 29 views
1

カスタムtableViewCellを作成し、データを入力しています。データはシミュレータに正常に表示されますが、デバイスにはデータが入力されません。以下は私のコードです。事前にお手伝いをいただきありがとうございます。これは本当に私をつかまえています。UITableViewデータはシミュレータに表示されますが、実際のデバイスには表示されません

のviewDidLoad:

- (void)viewDidLoad { 
[super viewDidLoad]; 
// Do any additional setup after loading the view. 
[self initColors]; 
[self initDB]; 
[self.pointsTableView reloadData ]; 
} 

numberOfSections/RowsInSection:

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

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

cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
ProfileTableViewCell *cell = (ProfileTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"ProfileTableViewCell" forIndexPath:indexPath]; 

if (cell == nil) 
{ 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProfileTableViewCell" owner:self options:nil]; 
    cell = [nib objectAtIndex:0]; 
} 

// Configure the cell... 
NSArray<NSString*> *keys = [self.dealNameCountDict allKeys]; 
NSString *k = [keys objectAtIndex:indexPath.row]; 

// should be a dictionary for businessNameLabel 
cell.textLabel.text = k; 
cell.detailTextLabel.text = [[self.dealNameCountDict objectForKey:k] stringValue]; 


return cell; 
} 
+0

@Mr JonesisMeこの設定をチェック: - プロジェクト - >ビルド設定 - >アーキテクチャタブ - >ビルドリリースをYESに設定 –

+0

NSArray * keys = [self.dealNameCountDict allKeys]; 'の保証はありません。 ' - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section'が呼び出されましたか? '-initDB'とは何ですか?それは非同期ですか?デバイスのtableViewをリストに表示しますか?それはシミュレータとレイアウト/制約の問題で異なるモデルですか? – Larme

+0

@Larme '(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section'が呼び出されました。私は 'dealNameCountDict'が非同期Firebaseコールから作成されたと思います。 – MrJonesIsMe

答えて

1

おそらく、テーブルビューをリロードした後、あなたの辞書を移入されています。デバイスは通常、シミュレータよりも少し速く動作します。データを非同期で取得すると、その原因が考えられます。

辞書の設定者でテーブルビューを再読み込みしてみてください。

- (void)setMyDictionary:(NSDictionary*)myDictionary { 

    _myDictionary = myDictionary; 
    [table reloadData]; 

} 
+0

それは私がやったことです。ありがとう。 – MrJonesIsMe

+0

@MrJonesIsMeこれを次のようにマークしてください:) – Maurice

0

表が作成されていたとviewDidLoad後に呼ばれた後dealNameCountDictを初期化し、別のファイルのローカル機能があったが判明。私はちょうどその関数の最後に

[self.pointsTableView reloadData ];

を追加し、これは、非同期の問題を解決しているようです。

関連する問題