Initialization problem when switching screens.

Asked 2 years ago, Updated 2 years ago, 47 views

1.

When the screen switches to the Segway, The values on the button change.;

The text value of the button is retrieved from the server and changed Click this button to change the screen, and when you come back,

The text value of the button returns to the text value specified in the storyboard;;

And if you leave the button text value blank on the storyboard, ("") Button text doesn't change;

2.

After specifying deligates and other values on viewDidLoad, When the screen is switched, all of the options seem to be initialized.

Therefore, many of the values in viewDidLoad were moved to viewDidAppear Is this the right way to do it?;

swift

2022-09-22 21:11

5 Answers

It is composed of static cells in tableview It is composed of views in stackview in static cell.


2022-09-22 21:11

It's a self-answer. // // self.btnNoticeContent_01.titleLabel?.text = content self.btnNoticeContent_01.setTitle(content, forState: .Normal) It's working well with the bottom one. Why did I do that? Where did I see it?


2022-09-22 21:11

I'm curious about number 2! Is it supposed to be like that? Every time the screen changes, viewDidAppear Do I have to reinitialize deligates and other settings?


2022-09-22 21:11

Isn't there an initialization process in viewWillAppear? Did you also designate Segue about back?


2022-09-22 21:11

Only one titleLabel exists inside the UIButton. And, whenever the button status changes (.normal, .highlighted), TitleLabel.text is newly set each time.

State-specific titles are stored inside the UIButton.

If you modify button.titleLabel.text directly, the title for each internally stored state does not change, so if it changes to another state and returns, the value returns to the initial value.


2022-09-22 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.