1

splitViewController の RootViewController で userName ラベル テキストを設定していますが、問題はありませんが、otherViewController で userName ラベル テキストを変更したいのですが、ルート Viewcontroller を開いたときに、新しい userName が取得されないことが原因で、リロードされない可能性があります。また。

4

1 に答える 1

0

最初に、別のクラスから Username を設定する場所にアクセスするために 1 つのグローバル変数を設定する必要があります。次に、特定の変数に Username を設定するために以下のメソッドを使用できます。

@protocolを使用して、他のクラスからクラスメソッドにアクセスできます

また

NSNotificationCenter次のように使用できます

メソッドに以下のメソッドを追加しますrootViewcontroller ViewDidLoad:-

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(actionNotificationData:)
                                                 name:@"reloadData"
                                               object:nil];

-(void)actionNotificationData:(NSNotification *)notification {

   //your code for variable logic

}

NSNotificationCenterそして、 reloadDataを呼び出したい場所から呼び出すためのベローメソッドを配置しますrootViewcontroller

[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
于 2013-07-11T08:00:14.897 に答える