Linkable blocks of text in Objective-C - objective-c

I encoutered an essential problem while making an iPad app, where u HUGE amount of text will be displayed.
I need to create blocks of text that can line break and also be linkable(for calling certain functions on each block). I thought that Core Text should be used.
Which is the way to assign the position of touch with necessary block of text?
and does anyone has any examples? google is poor on it, when it's about working with some amounts of text.

You can use a transparent button in overlay of the text.

You can not make your text linkable as in a html page. You can do this feature only in Webview.

Related

Embedding ZSSRichTextEditor in UITextView / UIWebView

I Would like to embed the ZSSRichTextEditor in UITextView / UIWebView.
I am having a form with fields which will be filled by the user. One of the fields needs to be formatted by user as in ZSSRichTextEditor. I tried the UITexView inline custom formatting. But failed to convert the attributtedString to HTML and the reverse. Any suggestions please.
ZSSRichTextEditor wasn't built to work with a UITextView. All the functionality that we built into it requires UIWebView to function. It IS an HTML editor.
If you try to force it to work with a UITextView, pretty much every function will no longer work.

How to layout the UIlabel object according to design spec in iOS

I have some difficult time in creating iOS screen to match with visual design provided by design team.
The design team has provided the spacing info for each screen which shows how much space each text needs to be apart from other UI element on the screen. This is attached for your reference. You can see here that the two text labels "Activate Your Account" and "A Verification link...." are placed apart by 25px.
The same thing I am trying to achieve in the storyboard. I am attaching the storyboard screen snapshot for reference.
From this you can see that I cannot keep exactly 25px b/w the two text labels because for the following issue
The text font is custom font and I cannot load the same in storyboard. I have added the font file in the project, but when I try to open it in storyboard for UILabel, it doesn't list out. I am not sure why xcode doesn't show up. This makes me hard to resize the label's frame. If I try to decrease the empty space in the label (upper and lower part of the text), this will make label height less, but when I set the font programmatically, it doesn't fit in this small space.
When I try to increase the height of the label, the text inside the label starts displaying at the center leaving space at the top and bottom of the label frame.
So I want to know how to solve this problem. If anyone had this issues and sorted out, please let me know how to fix this.
Many Thanks
Your designers aren't speccing their designs correctly :) Show them how iOS renders text and have them spec their designs in the same way. This is what we do on the Facebook design team. I mocked up an example for you (each square is 4dp/8px).
http://i.stack.imgur.com/q4tZX.png

iOS Text Wrapping

In the app I am currently developing, I have to implement a screen which allows the user to ask a question. This screen contains a UIImageView next to the UITextView, taking up a portion of the space. It looks like the below image.
My question is, how can I wrap the UITextView text around the UIImageView, so that the text won't be in a block, but flowing around the UIImageView?
Thanks in advanced.
I don't think you can do this, unless your UITextView was a rich text or HTML editor, with the image embedded inside it. Basically what you're asking for is a non-rectangular UITextView. To the best of my knowledge, that is impossible in iOS, unless you were to create something brand new from scratch, which would be extremely complex. I have seen plenty of UILabel-style controls that can display HTML-like text, but not edit it.
EDIT: this might help: http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
Unfortunately that's not a trivial issue as the UITextField does not provide any functionality that would be useful here.
However what you could do is to implement your own text view using UITextInput (for text input) and Core Text (for text display) and then define the drawing rectangle for Core Text (you can read more on Core Text here) from a custom CGPath that would exclude the images frame.
It does sound a bit complex (insane, perhaps), however as (nearly always) there are open source solutions that already found a solution. The OmniGroup framework contains custom text input controls based on Core Text and UITextInput. They're licensed under MIT License (well, moreless) so you should be just fine.

Tips on implementing a custom UITextView interface on the iPhone?

I am trying to implement a control to edit text that will display the text in multiple colors. None of the solutions I have attempted yet have been good enough.
UITextView cannot accomplish this. All of the text must be the same color.
Using CoreGraphics to draw the text does not allow the text to be selected.
Using a UIWebView, DIV and PRE tags cannot be set to contentEditable on Mobile Safari.
Currently playing with using an off-screen TEXTAREA and an on-screen DIV to show the rendered text. This works pretty well, except supporting all of these at the same time seems impossible: click-to-type, click-to-move-cursor, click-and-hold-select/copy/paste.
Anyone have any tips on this predicament?
I've been trying to find any preexisting library out there that will accomplish this in a good way, to no luck. I'm open to any ideas!
Well, just pulling an idea out of my... let's say hat.
Could you put a transparent UITextfield over a view that draws the text? If the background was clear and the text color was clear the user could not perceive it but it should still respond to all commands. As the user enters and edits text you could draw the results on the view underneath.
I think the selection would work without any modification at all. When the user selected the clear text, it should create the illusion of selecting the drawn text automatically.
Like this one? StyledText http://three20.info/gfx/overview/styledtext.png It's in Three20 .
Here is an idea. I have no idea if it would work.
If you are only using colors, and not styles, the a UIWebView with colored text might layout text in exactly the same way as a UITextView. You could put a UITextView with invisible ink (text and background fully transparent) over a UIWebView and mirror the contents with colors in the html. I assume you can do scrolling with javascript along with the colored layout.

Printing the Data in a NSTableView

How would print what is in my NSTableView? The View uses core data so everything is stored and can be grabbed as an NSArray. But how would I go about printing it out? At the moment when you click the print button it just seems to take a picture of the view and print that.
Yes, this works exactly as documented. The view is asked for its PDF representation (which, for an unmodified table view, is exactly what you see on screen), then this gets printed.
A view's drawing can be customized for printing versus on-screen drawing, but for a table view, this is more trouble than it's worth.
It might be easiest to generate an HTML representation of the table, then print that. You can use WebKit or just a plain NSAttributedString and off-screen NSTextView. The trick there is to generate the HTML, create an attributed string with the HTML data (there's a method just for that), then hand that to the off-screen text view. The text view would be sized as desired, then you just tell it to print. This gives you control over pagination as WebKit doesn't currently support the print-specific parts of CSS (in other words, it's "screen-only").
What I've done is taken the data and drawn it to a NSView based object in a way that the end-user would want to print. The user then prints that. it's in the docs.
I like Joshua Nozzi's idea, probably much simpler than custom drawing...