Now Playing Tracks

Reference documentation on your iPad Homescreen.

Quite handy for developers with iPads. Point Safari to http://developer.apple.com/iphone/library/iPad/index.html#home for iPhone or http://developer.apple.com/mac/library/iPad/index.html#home for Mac Reference Library. Touch the + button in the toolbar and select ‘Add to Home Screen’. Now you always have your Reference Library available, unfortunately only when you’r online though. I wish there was an offline app version of this…

set selectedRange in a UITextView

A short Cocoa Touch post as I could not immediately find the solution on the internets.

I wanted the cursor to be at the beginning of a UITextView when the user taps anywhere in that text view. The straightforward approach of doing it in the delegate does not work and I found a couple of posts saying so.

It turns out that performSelector:withObjects:afterDelay is your friend:

- (void)textViewDidBeginEditing:(UITextView *)inView
{
[self performSelector:@selector(setCursorToBeginning:) withObject:inView afterDelay:0.01];
}

- (void)setCursorToBeginning:(UITextView *)inView
{
inView.selectedRange = NSMakeRange(0, 0);
}

To Tumblr, Love Pixel Union