Autoscroll when UINavigationbar Prompt text is too long? - uinavigationbar

If I have a very long text as the prompt text, ex:
[[self navigationItem] setPrompt:[NSString stringWithFormat:#"This is a very long message which I want it to be scrolled. So that the user can read all the text."]];
How can I make it scroll automatically?
My solution is:
Set the promptText to nil.
Create a UILabel with the long text.
Animate the uilabel.position.x and use a loop.

Mostly Torn answers this question in his blog
http://blog.stormyprods.com/2009/10/simple-scrolling-uilabel-for-iphone.html

Related

UITextView scrolls up after "Speak"

I have a non-editable UITextView to display some text. Users can select the text in this UITextView and choose the iOS "Speak Selection" functionality (speak button) to read it for them. However, when 'Speak' is done reading the last word, it scrolls up the UITextView. In fact, even if I select just the last word in the text, and choose 'Speak', it scrolls up the UITextView.
I have scrollEnabled set to NO, editable set to NO, and the text is a NSAttributedString.
How can I stop the UITextView to scroll up in this case?
I can't comment with my reputation, unfortunately I don't have a real answer but a workaround; so far mine is to intercept [UITextView setContentOffset:animated] via method swizzling (http://nshipster.com/method-swizzling/) and avoid calling the original method when needed (this method is called by QuickSpeak function). I guess subclassing would be cleaner if you can instantiate the view yourself (this is not my case).

Can I make UITextField invisible?

I checked out iPhone: How can I make a UITextField invisible but still clickable?, but the OP has something else going on and the answers didn't seem to help me out of my fix.
I have a UITextField in which the user has to enter text. Instead of the standard UITextField graphic, I want to use a lovely graphic that's been designed for that purpose. The user would still need to be able to enter text and see the text s/he's entering, but I need the textfield to be invisible so that the graphic can show from underneath it.
How can I do this? Or is there another way to do what I'm after?
Adding my comment as an answer. You can try this,
[textField setBackgroundColor:[UIColor clearColor]];
And then set the border style as UITextBorderStyleNone.
something like:
yourTextField.borderStyle = UITextBorderStyleNone;
should do it
Another solution would be hiding the UITextView itself and just adding a transparent button that will call the keyboard to display.
Otherwise, the other answers should work.
Easiest option is to do it in interface builder. Choose the first uitext field style with no border and that's it.

Transparent Keyboard?

almost finished my App. All calculations, ..... are now working.
As I have several Text Fields on the view and when I'm showing keyboard, I cannot see what I typing Field it is hidden by the keyboard.
Do you have a method for showing transparent keyboard then people will be able to see by transparency.
Regards
You'll need to add the following code in your .m file for each view you want to add the transparent keyboard to:
- (void)viewDidLoad {
[super viewDidLoad];
textField1.keyboardType = UIKeyboardTypeDecimalPad;
textField1.keyboardAppearance = UIKeyboardAppearanceAlert;
textField2.keyboardType = UIKeyboardTypeDecimalPad;
textField2.keyboardAppearance = UIKeyboardAppearanceAlert;
}
textField1 and textField2 are just examples. you need to add these 2 lines for each field. It's guaranteed way, I have 2 apps with these and just updated them 2 weeks ago and they were never rejected.
****You should change to the keyboard type you want.**
You should read the "Keyboard Management" section of the "Text, Web and Editing Programming Guide" in Apple documentation.
In the "Moving Content That Is Located Under the Keyboard" paragraph, they explains how to manage the keyboard properly and how to scroll your view so that the current text field is always visible and never hidden by the keyboard.
(source: apple.com)
There's no such thing as a transparent keyboard. You need to move your text field so that it is visible when the keyboard is displayed.

on clicking a text view, always positioning cursor at the beginning

I have a text view. I have not implemented the UITextView Delegate Protocol in my .h, but in .m file I am overriding the delegate methods (shouldBeginEditing and endEditing) and the methods are getting called. Now, what I want to do is whenever user clicks on text view, I always want to position the cursor at the beginning (no matter where he clicks on the text view). I have tried using this lines in textview's BeginEditing method, but it was of no use.
[textView setSelectedRange:NSMakeRange(0, 0)];
I always want to allow user to enter new text at the beginning (don't want the text at the end of already entered text view's text). Someone pls tell me how to get rid of this problem?
PS: I working on ios , xcode 4.2....
UITextView*textView;
[textView setContentOffset:CGPointMake(0, 0) animated:YES];

How to write multiple lines in a label

I have a XIB file of type View XIB. In it I have a View controller, and in the View controller I have a label.
I have long text that I want to break, but it doesn't - it gets truncated.
I tried this solution - I did it in the attribute window - but it doesn't help.
You could use a TextView and disable the Editable and User Interaction Enabled options in IB.
use this
myLabel.lineBreakMode = UILineBreakModeWordWrap;
if you are worried about backwards compatibility use this because the comand i mentioned before was introduced in iOS 6.0
myLabel.numberOfLines = 0;
I have been running into a similar problem. I started out with a label, but wanted multi-lines and a UITextView worked great for this, at first. Because I am using a third party library (MBProgressHUD) to handle stuff like progress messages and what not, I had thread problems when trying to update a UITextView and show the progress message at the same time.
So I went back to UILabel which actually didn't have thread problems. I found a property to allow a specific number of lines of my choosing, and had to create the label big enough to display those lines. The downfall to this approach is that I don't get the context menus like Copy, Paste, etc. but more importantly I'm not running into thread problems. I can always embed this into a UIScrollView in the future if I so choose.
You could check out my category for UILabel on GitHub. https://gist.github.com/1005520
This lets you resize the height of the label to accommodate the content.
From the Attiribute inspector, choose LineBreaks->Word Wrap option when you have selected the lablel. Also increase the number of lines Label->Lines.
Try Following steps to solve issue :
Drag out a UITextView.
Double-click it to edit text, place cursor where you want the
paragraph break.
Option-Enter a couple of times to create a blank line & paragraph.

Resources