UITextView data change swift

You need to set UITextView delegate and implement textViewDidChange: method in it. Unfortunately, I do not know if swift documentation is available online. All the links go to the objective-c documentation. The code will look like this: (updated for SWIFT 4.2) class ViewController: UIViewController, UITextViewDelegate { //If your class is not conforms to the UITextViewDelegate … Read more

How to add image and text in UITextView in IOS?

This is absolutely possible now, using + (NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment See Apple docs here And this example taken from this other answer: UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,140,140)]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@”before after”]; NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init]; textAttachment.image = [UIImage imageNamed:@”sample_image.jpg”]; CGFloat oldWidth = textAttachment.image.size.width; //I’m subtracting 10px to make the … Read more

How do you make a vertical text UILabel and UITextView for iOS in Swift?

Edit: This is how I finally did it. Here’s a very basic implementation in my GitHub: Vertical-Text-iOS. Nothing fancy, but it works. Finally I had to mix TextKit and image processing. Take a look at the code. It involves: Subclassing NSTextContainer to get the right text dimensions. Creating a custom UIView to render the text … Read more

Hiding the Keyboard when losing focus on a UITextView

Simplifying tuzzolotron’s answer: Where the following outlet is properly connected in your xib IBOutlet UITextView *myTextView; Use this in the view controller: – (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; if ([myTextView isFirstResponder] && [touch view] != myTextView) { [myTextView resignFirstResponder]; } [super touchesBegan:touches withEvent:event]; } A tap on the View … Read more

How to show HTML text from API on the iPhone?

As David Liu said, UIWebview is the way to go. I would recommend a few building the HTML string separately and then passing it to the UIWebView. Also, I’d make the background transparent, using [webView setBackgroundColor:[UIColor clearColor]] so that you have an easier time making things look as they should. Here’s a code sample: – … Read more

Multi-line user input in iOS: UITextField vs UITextView

UITextField is specifically one line only. Use UITextView instead for multiline text. To implement the placeholder in UITextView use this logic/code. First set the UITextView to contain the placeholder text and set it to a light gray color to mimic the look of a UITextField’s placeholder text. Either do so in the viewDidLoad or upon … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)