Code Monkey home page Code Monkey logo

Comments (9)

IvanoBilenchi avatar IvanoBilenchi commented on June 17, 2024

I just reproduced the issue you're experiencing, and found a possible fix.

In ICTextView.m, line 196: change it to shouldApplyCharacterRangeAtPointFix = YES;

Let me know if it works okay after that change. I probably need to reapply that fix in iOS 9.x, even though it wasn't needed anymore in iOS 8.

Also, I just noticed you opened issue #10 long ago. It is referring to the same problem, right?

from ictextview.

DimonDeveloper avatar DimonDeveloper commented on June 17, 2024

Yes #10 it's the same problem and shouldApplyCharacterRangeAtPointFix = YES; didn't help.
Sorry that made a duplicate question, the old you just did not respond.

from ictextview.

IvanoBilenchi avatar IvanoBilenchi commented on June 17, 2024

That's strange, that works in the sample project.

To be clear: in the sample app, if the fix is disabled, calling setContentOffset: "very early" such as in viewDidLoad has no effect, while it works okay if the fix is enabled.

I may need some sample code. Can you setup a project where the problem you're referring to is reproduced? Thanks!

from ictextview.

DimonDeveloper avatar DimonDeveloper commented on June 17, 2024

TextViewSample.zip
I created the sample project.

  1. Click "Open text" button
  2. Scroll down and remember position
  3. Click "Close" button (position remain to NSUserDefaults)
  4. Click "Open text" button again and the previously stored position does not set. (in viewDidLoad position from NSUserDefaults set in setContentOffset)

from ictextview.

DimonDeveloper avatar DimonDeveloper commented on June 17, 2024

How do you think, what is the problem?

from ictextview.

IvanoBilenchi avatar IvanoBilenchi commented on June 17, 2024

I've been pretty busy over the past few days, should have some time to look into this in a few more days. Thanks a lot for the sample project!

from ictextview.

IvanoBilenchi avatar IvanoBilenchi commented on June 17, 2024

I had a look at your project, and it looks like the issue you're describing also happens if you replace ICTextView with a default UITextView, as can be seen in this sample project:

TextViewSample_UITextView.zip

I don't currently have much time at hand to troubleshoot this, but it's probably due to UITextView not being fully laid out during viewDidLoad. You may have some luck experimenting with viewWillAppear:, viewDidAppear:, viewWillLayoutSubviews and the likes.

Something that does indeed work is saving the location of the currently visible range, and restore it on viewDidLoad. This completely bypasses setContentOffset: by using some useful API I built into ICTextView, namely the visibleRangeConsideringInsets: and scrollRangeToVisible:consideringInsets: methods, as shown in the following sample project:

TextViewSample_Fixed.zip

It won't scroll to exactly the same point, but the text you were previously reading will definitely be on top.

from ictextview.

DimonDeveloper avatar DimonDeveloper commented on June 17, 2024

@Exile90 Thank you very much, your fix helped.
In scrollRangeToVisible, if to increase "location" on 12, it shows almost the same point.

CGFloat location = [[NSUserDefaults standardUserDefaults] floatForKey:@"textLocation"]; [TextView scrollRangeToVisible:NSMakeRange(location + 12, 0) consideringInsets:YES];

from ictextview.

IvanoBilenchi avatar IvanoBilenchi commented on June 17, 2024

I'm glad that helped. I hope you'll find the best implementation for your use case.

I'll close this issue and #10. Feel free to open a new issue if you find any other bugs, or keep commenting here if there's more to this specific issue.

from ictextview.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.