ich eine UITextView bin mit einem langen Text in ViewDidLoad angezeigt werden():UITextView nicht nach oben macht Blättern
var story1 = "Researchers on Friday introduced the stunningly realistic-looking interactive humanoid robot to the world, and she reacted by nodding her head, squinting, moving her hand and eyeballs and telling assembled local photographers, with her speech synched to her lip movements, to snap her face from a more flattering angle. Girl's got spirit. \n\nJia Jia made her public debut at the University of Science and Technology of China, where she came to life over the course of three years. While her rosy cheeks and pink lips make her look like she has blood running through her actuators, she still has a way to go before she'll be confused with a human. Her expressions are currently limited to 'microexpressions' and her speech has that distinct stiffness that screams 'I am a robot and I will one day chase you from your home'\n\......." //a very long text with many rows
self.StoryTextView.text = story1
Wenn ich auf „Scrolling Aktiviert“ für StoryTextView, zeigt die Textview den Text nicht von Anfang an . Ich kann den Scrollindikator in der Mitte (oder unten) des Textes sehen.
versuchte ich self.StoryTextView.scrollsToTop = true aber es hilft nicht.
Wenn ich "Scrolling Enabled" deaktiviere oder wenn der Text nicht zu lang ist, um den gesamten Text in einem UITextView anzuzeigen, wird er wie erwartet von Anfang an angezeigt. siehe Screenshot2.
Gibt es eine Möglichkeit, den langen Text vom Anfang des Textes anzuzeigen (Scrollindikator nach oben bewegen)? Ich habe Einschränkungen und Layout überprüft, aber es scheint nicht verwandt zu sein. Ich habe viel gesucht, aber bisher kein Glück. Ich könnte eine einfache Einstellung verpasst haben, aber jeder kann mir bitte helfen.
Vielen Dank.
danke. Du hast Recht. Und ich weiß aus der Antwort einer anderen Frage, dass dies in viewDidLayoutSubviews() getan werden muss. http://stackoverflow.com/questions/28053140/uitextview-is-not-scrolled-to-top-when-loaded – Adaoli
Ich füge dies hinzu und das Problem gelöst. 'überschreiben func viewDidLayoutSubviews() { self.StoryTextView.setContentOffset (CGPointZero, animiert: falsch) }' – Adaoli
Swift 3: CGPointZero -> CGPoint.zero – Darko