Text Highlighting with the play back sound or voice - iphone

i have a requirement to highlight the text when the sound is played in the back ground as like toy story book but i don't have idea how to do it. Some body was telling that calculate the time of each word and do it but it is lengthy process because there are around 50 pages and for each page there is at least 100 words. for calculating the 100 word length and synchronize
the animation with the voice is very typical task. Please if any body have some sample code then please share it. I am in the critical condition at this point i got stuck at this point of time. Please help me.

There are at least two ways for this task:
Use CoreText to implement a custom UIView that display custom format for specific texts based on progress of readings.
Use a UIWebView, populated with content of text, with each text wrapped within tag like <span>. Using JavaScript and CSS to dynamically change the format of the texts based on progress of readings.
Either way you dont need to mess with low level text sizing. You may also consider highlight the text by each paragraph rather than each words, if your requirement permit.

Related

Composing a pdf-file by filling a pdf-form programmatically or by composing a SwiftUI-View and convert it to a pdf?

I have a question for the best approach to code an app with the ability to convert a SwiftUI View into a PDF-file.
With my app I want to enable the users to compose a PDF-file with an image, with texts, with links and with some calculated values for later printing by AirPrint and sending as an email-attachment
What is the right way to go in coding with SwiftUI:
Composing a View, rendering the View and thereafter creating the PDF
or
is it possible to prepare a PDF-form with Adobe DC, then use the app's data for filling it programmatically with the help of the ?framework PDFKit? including images and maybe an empty table as well?
Thx for any helpful hint.
I don‘t wait for any code, please just send some words for my further working in your opinion.
Franz

Synchronized recorded video and text playback - iPhone

I'm a new developer and I want to know if it is possible to record a video and process it so that specific text is displayed above/below or inside the video.
Specifically, my educational app displays random words in a text label at a regular interval, and I want my user to be able to record himself saying those words with the front facing camera. Then I'd like to save that video with the words added to it-- that means that during video playback the user would see all of the words come up as he saw them during recording.
I'm wondering if this text display (and synchronization) are possible.
Does anyone have any suggestions or pointers in the right direction (if this is even possible)?
Apple has a ton of documentation on Core Media Time.
Create a list of times at which you want each word to appear and disappear, then compare those times against the running time of the recording in a timer or frame rate callback, to decide what word to (re)draw onto a view or layer.
As long as the videos are in full (there are no stops at all) and they are recorded at the same frame rate then you just need to find one point that you can find the sync point and the rest will be in sync. Another option is to record the timestamp of when the text you want to appear. That way you can subtract between two texts to get the duration of the text.

How would you design a question/answer view (iPhone SDK)

I'm new to iPhone development, and I have a question on how to create a view for my application.
The view should display a problem (using formatted/syntax highlighted text), and multiple possible answers. The user should be able to click on an answer to validate it.
Currently, I am trying to use a UITableView embedding UIWebView as contentView. That allows me to display formatted text easily.
The problem is that it is a real pain to compute and adjust the height of the cells. I have to preload the webview, call sizeToFit, get its height, and update the cell accordingly. This process should be done for the problem and the answers (as they are HTML formatted text too).
It's such a pain that I am planning to switch to something else. I thought using only a big UIWebView and design everything in HTML. But I looked at some articles describing how to communicate between the HTML page and the ObjectiveC code. This seems to involve some awful tricks too...
So... that's it, I don't really know what I should do.
I guess some of you dealt with such things before, and would provide some greatly appreciated tips :)
The catch here is that the iPhone API does not yet support NSAttributedString so you can't just set the text to appear as you would like in a textview.
I saw one work around which essentially used individual UILabels to represent each attribute run. (Can't find the link now.) They used NSString UIKit extensions to calculate the position of the strings on the view and then used that to position the labels.
Another work around would be to draw the strings with their attributes to a UIImage and then just display the image. That would be the easiest solution I think.
In either case your going to have to basically recreate the data structure of an attributed string.
NSAttributedString does a lot of work for us. We really miss it when it is gone.

Text input box like the SMS app on the iPhone

I am having a terrible time trying to get an input box like the one in the SMS app.
Can anyone offer some guidance on how to build one of these and make it look good? I need an input box that is shaped nicely like the UITextfield but will stretch vertically when typing.
I assume that I need to calculate width of the text and stretch the overlay image frame vertically when the text word wraps. The closest I have come does stretch but the cursor bounces all around when nearing the boundaries.
UPDATE:
I have worked on this everyday for a week and I have about given up on the UITextView. I can get it to stretch properly but when backspacing, the Textview height shrinks too much when going up a line. As I continue backspacing it corrects itself. For example, it displays this behavior when I am on line 4 and backspace up to line 3. Then as I continue backspacing, it corrects until I get to the end of line 2. Then it corrects itself,.... etc.
I decided to try to subclass UITextField but I can't even get it to display in the Frame size that I specify. 150,150,150,150.
Try Chat Input Sample. It has the similar look and functionality of SMS app.
Three20 project has a control that should do this for you.
From the Three20 README:
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 get to do this yourself. Luckily, the UITextField can notify you whenever its text changes using UITextFieldTextDidChangeNotification, and luckily NSString has methods (under the UIKit Additions) that let you get the height of the string given a certain width using boundingRectWithSize:options:attributes:context:, and luckily you can resize a UITextField yourself using frame.
I know this is old but for the people that still look at this answer there is now a nice control from Slack that does that called SlackTextViewController.

How should I implement an editable rich document view for the iPhone?

I want to implement a view in an iPhone application that is essentially like a rich text document. I need it to be click-editable, and I'd like to be able to embed graphic objects (either an overlaid view object, or manually drawn in graphic) with the text wrapping around. much like you would expect in a word processor. That's about the minimum functionality needed. Changing font for certain text would be a bonus (bold, size, etc).
UITextView would be a great start for me if it supported media like graphics embedded.
I'm still very new to Cocoa and Obj-C. Where should I start?
UITextView will not be nearly sufficient -- it has a very well-defined and simple functionality. That is an extremely complicated thing you're trying to do, wrapping text around an image -- you'll have to use to manually render the text in your drawRect method and do some very complex collision detection and calculate the string sizes etc. It's do-able, but extremely complicated.
Now, if you don't want the text to hug the image, but rather have the two appear on distinct lines, then you could fake this with a UITextView, then a UIImageView, then a UITextView, manually changing size and offset of each as the text changes...but this is a cheap hack and not exactly extensible. It could be sufficient for your needs, however.
UITextView does not allow rich formatting (bold, italics, different sizes, colors...), so that too would require a custom sort of text view.
Basically, it's a pretty big undertaking. If you're really committed, I recommend what Alex said -- get very, very comfortable with UIKit and Objective-C and iPhone coding in general. Then research how to make a rich text editor in other languages more suited to the functionality, and try porting that to the iPhone.
Hope this doesn't sound too discouraging. It's possible, but it won't be easy. And always bear in mind that the iPhone is a phone. Is it really the best platform for your application?
You might start with a much smaller, unrelated project. A viewer is no problem — start with UIWebView, which can render a RTF document for viewing. Creating a document editor, however, is no small task.