Xcode - update ViewController label text from different view

后端 未结 4 2040
予麋鹿
予麋鹿 2020-12-01 21:54

I have two view Controllers in my project ViewController, SettingsView. Here I am trying to update the ViewController\'s label, when i

4条回答
  •  情书的邮戳
    2020-12-01 22:52

    Simply declare like this in SettingsView class:

     UILabel *lblInSettings;// and synthesize it
    

    Now assign like below when you presenting Settings viewController:

    settingsVC.lblInSettings=self.myLabel;
    

    Then whatever you update in lblInSettings it will be present in MainView obviously.... no need for any delegate methods or updating methods.

    Means if you assign at the time of dismissing like
    lblInSettings.text=@"My new value";
    then self.myLabel also will be updated.
    

    Let me know if you have any queries?

提交回复
热议问题