Swift- Setting uitextview text compress the text size - swift

In iOS 8 on iPad device, i tried to set UITextView text in Code file. It just compresses the text size. Event i have tried this one.
myTextView.text = myTextView.text
It also compressed the text size. I don't know why UITextview is behaving like this in iOS 8
OR is this because XCode-6 is of Beta version and may have bugs?

OMG! I can't believe it. I've disabled the UITextView's Selectable propery in Interface Builder. When i enabled it again. It just resolved the issue.
Although, i have resolved the issue, but it has left a question for me. Is this Apple's issue or of something else?

Related

Black dot in UITextField, instead of Placeholder text, when using Auto Layout in Xcode 9.2

After upgrading to Xcode 9.2, I have had a strange issue in Auto Layout with all the placeholders in my UITextFields.
Did anyone find a solution to this problem?
If using storyboard Just Uncheck secure text entry.
//or if using code
youtTextFieldName.isSecureTextEntry = false

Caret cursor color and size

How do I change the size and colour of the flashing cursor in my textfield using my storyboard for my Mac app.
I assume I have to connect it into the view controller script (control drag) and edit some uitextfield color parameter for the cursor?
But I don't seem to be getting anywhere fast. I am working in swift 2.2 with Mac app Storyboards. Like Ulysses and Taskpaper.
In Swift 3:
Change YOURTEXTFIELD to your textfield and you are set:
(YOURTEXTFIELD.value(forKey: "textInputTraits") as AnyObject).setValue(UIColor.black, forKey: "insertionPointColor")
Documentation: https://developer.apple.com/documentation/appkit/nstextview/1449309-insertionpointcolor
Search for _drawInsertionPointInRect that's the private method that you need. Though you also need some other stuff I think... but it's all mixed into my code so I can't say for sure what it all is. Anyway search for _drawInsertionPointInRect and you'll get to some explanations.

UITextView Puzzle?

In one project XCode4 intellisence feature shows setContentToHTMLString method of UITextView but in other project intellisence feature not showing setContentToHTMLString this method of UITextView.
I want to use setContentToHTMLString method of UITextView for HTML-based Presentation-only in my textView this works in one Project but not showing even by the intellisence feature of UITextView.
Any Suggestion.
Thanks in Advance....
I don't know why Xcode has this changing behavior, but I would suggest you not to use that method, because it is in a private API, so your app would be rejected by Apple. Possibly the fact that it is private is also why sometimes it is showing (it should not), others it is not.
The way to go to display HTML content is either use a [UIWebView][2], with all its caveats, or try out Three20 styled text facilities, which are quite limited, though.

Why does UIWebView keep detecting phone numbers?

I have a UIWebView with detect phone numbers unchecked. However, it keeps underlining the numbers in this text:
Version: 2.1 3.19.2009
The text isn't in an anchor or anything. Is there a way to force the UIWebView to not detect phone numbers?
Try
webview.dataDetectorTypes = UIDataDetectorTypeNone;
It looks like there is a problem with Interface Builder's UIWebView attributes palette; the "Detects Phone Numbers" checkbox does not seem to have any affect. Examining the UIWebView's detectsPhoneNumbers property at runtime shows that it was not actually modified by IB.
For now, setting the detectsPhoneNumbers property in code to "NO" will work fine. The problem is only with the IB palette.
Unless we're both missing something, this is a bug. I'd suggest filing it at http://bugreport.apple.com/. Additionally, you can post it at http://openradar.appspot.com/ if you'd like to make it visible to other developers.
Swift 3+ programmatically
webView.dataDetectorTypes = []
[webview setDetectsPhoneNumbers:NO];
It will work for you.....

UITextview content moves up when textview is selected

I am pretty new to this iPhone dev thing but so far I have built a pretty good app but I have stumbled into this problem that for the life of me I cannot seem to solve.
Basically the app is a chat application for social site. Everything is working 100% except the input box which currently is a UITextbox. This works fine however I would like the box to grow and be a multiline UITextbox with scroll. I replaced the UITextbox with a UITextview and all is good. I have the UITextview expanding as the user enters text however I have one slight problem that is driving me nuts.
When the UITextview gets focus it shifts the cursor and any text in there up just out of view. The UITextview I have set to display 2 lines by default and then as the height of the text goes beyond those two lines I would like the box to grown (which it does) and the text to remain scrolled up so you can see what you are typing. If you look at the SMS app on the iPhone this is exactly how I would like it work.
Any words of wisdom would be greatly appreciated.
I think Blaenk answered perfectly (that was going to be my answer). But just in case you don't want to include Three20 in your project (it's kinda big), below is the relevant code from TTTextEditor. You should be able to call this from wherever you are expanding the text view.
- (void)scrollContainerToCursor:(UIScrollView*)scrollView {
if (_textView.hasText) {
if (scrollView.contentSize.height > scrollView.height) {
NSRange range = _textView.selectedRange;
if (range.location == _textView.text.length) {
[scrollView scrollRectToVisible:CGRectMake(0,scrollView.contentSize.height-1,1,1)
animated:NO];
}
} else {
[scrollView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];
}
}
}
Check out three20:
Three20 is a collection of iPhone UI classes, like a photo viewer, and general utilities, like an HTTP disk cache. Three20 is derived from the Facebook iPhone app, which is one of the most downloaded iPhone apps ever.
Specifically, you'll want to take a look at TTTextEditor:
TTTextEditor is a UITextView which can grow in height automatically as you type. I use this for entering messages in Facebook Chat, and it behaves similarly to the editor in Apple's SMS app.
You'll find instructions on how to add three20 to your project here.
I made a subclass of UITextView just for that:
https://github.com/MatejBalantic/MBAutoGrowingTextView
It is an auto-layout based light-weight UITextView subclass which automatically grows and shrinks based on the size of user input and can be constrained by maximal and minimal height - all without a single line of code.
The class is made primarily for use in Interface builder and only works with Auto layout.