How to add a background image to a table view

The easiest way to do this is by adding a UIImage to your table. Rather than instantiating a new table object you can simply add the following line into the first Table View Data Source method you have – such as this one: – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { tableView.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@”background.jpg”]]; // Return the […]

How to react to a UIAlertView

An alert view has the clickedButtonAtIndex property. The first clicked button is 0, the next one 1, and so forth. If you conform to the UIAlertViewDelegate protocol you can implement the following method and react to each pressed button accordingly, or…

How to show the Network Activity Indicator (spinning wheel in the iOS status bar)

Here’s how you start it: UIApplication *application = [UIApplication sharedApplication]; application.networkActivityIndicatorVisible = YES; And this is how you stop it: UIApplication *application = [UIApplication sharedApplication]; application.networkActivityIndicatorVisible = YES; Comes in handy when displaying a UIWebView or performing any other activity that requires the user to “hang in there for a bit”. If you want to […]

How to pass an Index Path to another table

Say you have a central array somewhere and would like display this in more detail via two table view controllers. Instead of passing only the relevant information, you want to pass the entire index path from table1 to table2 and beyond. You can pass data in the prepareForSegue:sender method and let the Storyboard to the […]

How to create a custom button

We can do this by setting properties of the UIButton for the states “normal” and “highlighted”. First we create pointers to the images, then we tell the button to use said images for each state: If the button has transparency enabled use the “custom” setting in your Storyboard. If the button should have a dynamic […]

How to add the “spinning wheel” Activity Indicator to a web view

It’s always good to have something happening while you’re loading a UIWebView. You can use the UIActivityIndicator for this. It’s basically an animated GIF file that you can connect to your code like many other elements. To make it work we need to conform to the UIWebViewDelegate protocol and then query our web view to […]

How to convert an NSArray into an NSMutableArray

There’s a handy function called arrayWithArray that we can use: NSMutableArray *myNewArray = [[NSMutableArray alloc]init]; myNewArray = [NSMutableArray arrayWithArray:myOldArray]; Likewise we can convert a mutable array into a standard one: NSArray *myStandardArray = [[NSArray alloc]init]; myStandardArray = [NSArray arrayWithArray:myMutableArray];