Posts Tagged ‘help’

Forcing a call to viewDidLoad

When loading a view controller from a NIB, you sometimes need to make sure it sets up fully well ahead of actually presenting its content on screen. Even though you’ve initialised the object from the NIB file you might be surprised not to see a call into viewDidLoad, this only happens normally when the view is about to be shown. Solution? Access the view controller’s view property and the load will complete immediately.

Tip: finding which UITableViewCell you’re in

If you ever put buttons in table cells, you’ll often want to know which cell a button’s in when someone clicks it. Here’s a quick method that will return the UITableViewCell object that contains a given UIView

// Scan up through the superviews of the sender to find the nearest UITableViewCell
-(UITableViewCell *) locateParentCell: (id) sender {
// Get a working reference
id obj = sender;
// Parse through each parent
while (![obj isKindOfClass: [UITableViewCell class]]) {
obj = [obj superview];
}
// Pass back the item
return obj;
}

 

Getting the size of UIWebView content

Working out how large to make a UIWebView in order to show all its content in one shot, without the need to scroll can seem daunting. Fortunately there’s a handy little trick for doing it. Implement the UIWebViewDelegate protocol within your...

Read more

Fake multithreading

Short note on how not to do multithreading in your iOS app. For new developers, the existence of the performSelector method must seem like a real gift. On the face of it what it appears to offer is the ability to...

Read more