objective c - Change NavigationBar Text from Different ViewController -
I have been a similar question posted before this one, but now clearly a more my codes The question is more information. I currently have a UITextField and a ViewController (SignUpViewController) with a UIButton I have a Uainevigeshnbar which is a view controller (Profailwukantrolr) I want to be able to type a username in TextField in SignUpViewController, UIButton in Tap, then the NavBar text in the profileview controller is set to the text in the TextField of the SignUpViewController. The problem is that, I can not use the UITPlayfield profile ViewController. I currently have an NSString in the title "AdvilGate" in my title and I am trying to use it as a solution. If my question is completely difficult to understand because it is thrown to you, below is my code, stack overflow:
SignUpViewController:
- (IBAction) submitButton {ProfileViewController * profileVC = [[Profile View Control Alloc] initWithNibName: Zero Bundle: Zero]; [Self-present ViewController: animated profileVC: yes complete: zero]; AppDelegate * appDelegate = (AppDelegate *) [[UIApplication shared application] representative]; AppDelegate.titleString = @ "Profile"; AppDelegate.titleString = Username TextField.text; } - (zero) viewDidoad {AppDelegate * appDelegate = (AppDelegate *) [[UIApplication ShareApp] representative]; [Super viewedload]; } Profailwukantrolr:
- (minus) Drishydidlod {app Diliget * App Diliget = (Aepdileget *) [[UIApplication share Apikling] delegate]; Self.title = appDelegate.titleString; [Super viewedload]; } It works fine until I tap submitButton in SignupViewController. What's going on here?
There are several things that you can do to overcome data between view controllers.
1) Set up a representative method. The profileviewer will be representative of the signInViewController. When the sign in button is pressed, the Signin V will call the Vicentrular representative configuration, which is listening for the profileview controller, which passes through the profile view controller title.
Sign in Inviyu controller:
@ protocol signed Indeted @required - didSignInWithTitle (zero): (NSString *) title; @end @ interface sign invoice controller: UIViewController @property (nonatomic, assign) id & lt; SignInDelegate & gt; Representative; Then when you allot your profile, your profile will be set as a votitor delegate:
signInViewController.delegate = profileViewController > This is your profileviewer:
#import "signinux controller." @ Interface profile WiAntroller: UIViewController & lt; Sign InDeliget & gt; Finally, make sure your ProfileViewController implements - (zero) didSignInWithTitle: (NSString *) header; Method. 2) You can use NSNotificationCenter to post a custom notification with attached title. This would be useful if you have many other views that want the controller to set a title like a profile.
#define UPDATE_NAVBAR_TITLE @ "UPDATE_NAVBAR_TITLE" When signed Invoice Controller is done: [[NSNotificationCenter defaultCenter ] PostNotificationName: UPDATE_NAVBER_TITLE object: zero]; After that, make sure that you add the profileview controller as an audience: [NSNetification Center Default Center] addObserver: Self Selector: @ Name (navbarUpdated) Name: UPDATE_NAVBAR_TITLE Object: Zero]; I recommend the first thing for what you are asking. Congratulations!
Comments
Post a Comment