だから私はiPhone版のTableviewでViewControllerを作成し、素晴らしい作品を作成しました。Popoverテーブルビューでセルを選択した後にUILabelがリフレッシュされない
iPad版では、テキストだけがあればテーブルビュー全体を画面全体に表示することはできません。だからiPadのストーリーボードでは、カスタムViewControllerにテーブルビューで接続されたボタンをメインビューコントローラに作成し、代わりにポップオーバーとして開きます。
開いていると、データがViewViewを使用してメインビューに渡されています。コンソールでは、ラベルが更新されているのが見えますが、画面上ではラベルは更新されません。
私がデータを取得するために使用した方法で試した[self.view layoutIfNeeded]
、他の回答で示唆された一部の人々としてアルファを変更します。私はviewWillAppearがまったく呼び出されないことに気づいた。 didSelectRowAtIndexにメインのvc viewWillAppearを設定しようとしました...
私は別の画面に移動して戻ってくると、もちろんラベルが更新されます。
ここでは、ポップオーバーでセルを選択したときに、テーブルビューでView Controllerを解除する方法を示します。
[self dismissViewControllerAnimated:YES completion:^{
[vc viewWillAppear:YES];
[vc.view layoutIfNeeded];
[vc updateText:[arrUsers objectAtIndex:indexPath.row]];
}];
メインビューコントローラーが更新されないようにすることは控えていますか?
これは、ポップオーバーのメソッドです:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIStoryboard * storyboard = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ?
[UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil] :
[UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController *vc = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ?
(ViewController*)[storyboard instantiateViewControllerWithIdentifier:@"ViewControlleriPad"] :
(ViewController*)[storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if(searching){
if ([copyListOfItems count]>0) {
NSLog(@"Search Results Selected %@", [copyListOfItems objectAtIndex:indexPath.row]);
[vc.lbl_specialties setText:[copyListOfItems objectAtIndex:indexPath.row]];
}
}
else {
self.appDelegate.selectedSpecialty = [arrUsers objectAtIndex:indexPath.row];
NSLog(@"Selected %@", self.appDelegate.selectedSpecialty);
}
[self dismissViewControllerAnimated:YES completion:^{
[vc viewWillAppear:YES];
[vc.view layoutIfNeeded];
[vc updateSpecialtyText:[arrUsers objectAtIndex:indexPath.row]];
}];
}
}
これは、上記と呼ばれているビューコントローラのメソッドです。代わりに
[self dismissViewControllerAnimated:YES completion:^{
[vc viewWillAppear:YES];
[vc.view layoutIfNeeded];
[vc updateText:[arrUsers objectAtIndex:indexPath.row]];
}];
の私の意見では
-(void)updateSpecialtyText:(NSString*)text
{
[super viewWillAppear:YES];
NSLog(@"text to update %@", text);
[self.lbl_specialties layoutIfNeeded];
[self.view layoutIfNeeded];
[self.lbl_specialties setText:text];
NSLog(@"text updated %@", self.lbl_specialties.text);
}
「vc」の値はどこで得られましたか? – trungduc
@trungducメインViewControllerをインスタンス化します。 'ViewController * vc =(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad)? (ViewControllerを*)[ストーリーボードinstantiateViewControllerWithIdentifier: "ViewControlleriPad" @]: (ViewControllerを*)[ストーリーボードinstantiateViewControllerWithIdentifier: "ViewControllerを" @]; ' – GunplaGamer
は、あなたがそれ原因編集した質問@trungduc – trungduc