Comments (3)
I think it would be better to position it at the end of the found range. That way the user can just hit the 'backspace' key to delete text (that's the most common scenario). Don't you agree?
from ictextview.
yes, it makes sense
from ictextview.
I just had a look into this: while it's indeed possible to do this programmatically within ICTextView
, it actually doesn't have the expected results. I'll describe a common scenario: when you search for a match, you're likely typing text into a UISearchBar
, UITextField
or another UITextView
, meaning ICTextView
is not the first responder (and the cursor is thereby not shown).
When you hit the "search" button, ICTextView
scrolls and highlights the relevant results, but whenever the user taps into it (in order to make the cursor appear), the cursor is placed depending on where the tap event occurred, invalidating any previous automatic cursor placement.
This would probably work if ICTextView
automatically became first responder whenever a search is performed, but then the user would lose the ability to perform multiple subsequent searches, not to mention that it's generally bad practice for controls to automatically get focus.
Furthermore, setting the cursor position means calling setSelectedTextRange:
or setSelectedRange:
, which are extremely inefficient under iOS 6.x and older (they tend to block the UI thread when UITextView
is handling a lot of text).
You can see this is not a very nice outcome in any case. If you need this, you may have luck by playing around with setSelectedRange:
and ICTextView
's rangeOfFoundString
property, maybe even with the UIScrollViewDelegate
methods, though again you'd have to provide your own workaround to user generated touch events.
from ictextview.
Related Issues (10)
- Work With Interface Builder? HOT 3
- setContentOffset not working correctly.
- How scroll to position? HOT 9
- ICTextView changes position after rotate device from Portrait to Landscape mode. HOT 2
- Search skipping highlights HOT 5
- Add a scroll direction would be better ? HOT 3
- Is there a way to integrate this to a webview? HOT 1
- not working with iOS 8 bridged to swift( HOT 2
- consideringInsets:YES results in no scrolling at all. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ictextview.