Uploaded October 2012 | Updated September 2026, 2 weeks ago
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel
Use an activity indicator to show that a task is in progress. An activity indicator appears as a "gear" that is either spinning or stopped.
You control when an activity indicator animates by calling the startAnimating and stopAnimating methods. To check if the activity indicator is animating we use the isAnimating property. To automatically hide the activity indicator when animation stops, set the hidesWhenStopped property to YES.
Starting in iOS 5.0, you can set the color of the activity indicator by using the color property.
It also has an activityIndicatorViewStyle property, which can take one of the following 3 values:
UIActivityIndicatorViewStyleWhiteLarge, UIActivityIndicatorViewStyleWhite, andUIActivityIndicatorViewStyleGray.
For more details, please visit Apple's Online Documentation at:
developer.apple.com/library/ios/#documentation/UIKit/Reference/UIActivityIndicatorView_Class/Reference/UIActivityIndicatorView.html
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel
Use an activity indicator to show that a task is in progress. An activity indicator appears as a "gear" that is either spinning or stopped.
You control when an activity indicator animates by calling the startAnimating and stopAnimating methods. To check if the activity indicator is animating we use the isAnimating property. To automatically hide the activity indicator when animation stops, set the hidesWhenStopped property to YES.
Starting in iOS 5.0, you can set the color of the activity indicator by using the color property.
It also has an activityIndicatorViewStyle property, which can take one of the following 3 values:
UIActivityIndicatorViewStyleWhiteLarge, UIActivityIndicatorViewStyleWhite, andUIActivityIndicatorViewStyleGray.
For more details, please visit Apple's Online Documentation at:
developer.apple.com/library/ios/#documentation/UIKit/Reference/UIActivityIndicatorView_Class/Reference/UIActivityIndicatorView.html



![How to create a custom cell programmatically in iOS
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
http://www.techytube.com/author/pavel
A cell in a UITableView is an object of UITableViewCell class, and can have one of four styles, which are:
UITableViewCellStyleDefault, UITableViewCellStyleSubtitle, UITableViewCellStyleValue1, and UITableViewCellStyleValue2, and you can use those according to your apps specifications, or you can create your custom cells.
In this video tutorial we will create a custom cell programmatically. For that we have to do most of our work in the tableView:cellForRowAtIndexPath: method. First we need a dataSource to populate the cell with info, so declare a private property for that, in the VieController.m file, just after the #import statement:
@interface ViewController ()
@property (nonatomic, retain) NSMutableArray *dataSource;
@end
Then, in the viewDidLoad method allocate and initialise that:
self.dataSource = [NSMutableArray array];
[self.dataSource addObject:[NSArray arrayWithObjects:@20, @JUN, @7:00PM, @Toyota Center, @Houston, TX, @FROM, @$200, nil]];
[self.dataSource addObject:[NSArray arrayWithObjects:@6, @JUL, @8PM, @Frank Erwin Center, @Austin, TX, @FROM, @$350, nil]];
In the tableView:numberOfRowsInSection: method return self.dataSource.count.
In the tableView:cellForRowAtIndexPath: method write:
// Each subview in the cell will be identified by a unique tag
static NSUInteger const kDayLabelTag = 2;
static NSUInteger const kMonthLabelTag = 3;
// ... and so on
static NSString *CellIdentifier = @Cell;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *dayLabel;
UILabel *monthLabel;
// ... and so on
if (cell nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// Define the frames for each component of the Cell
CGRect dayFrame = CGRectMake(5, 7, 64, 30);
CGRect monthFrame = CGRectMake(5, 35, 64, 16);
// ... and so on
// Adjust all the controls correspondingly
dayLabel = [[UILabel alloc] initWithFrame:dayFrame];
dayLabel.tag = kDayLabelTag;
dayLabel.font = [UIFont boldSystemFontOfSize:30.0f];
dayLabel.backgroundColor = [UIColor clearColor];
dayLabel.textColor = [UIColor darkGrayColor];
dayLabel.textAlignment = NSTextAlignmentCenter;
monthLabel = [[UILabel alloc] initWithFrame:monthFrame];
monthLabel.tag = kMonthLabelTag;
monthLabel.font = [UIFont boldSystemFontOfSize:16.0f];
monthLabel.backgroundColor = [UIColor clearColor];
monthLabel.textColor = [UIColor colorWithRed:0.0f/255.0f
green:140.0f/255.0f
blue:220.0f/255.0f
alpha:1.0f];
monthLabel.textAlignment = NSTextAlignmentCenter;
// ... and so on
// Add all created components to the new Cell
[cell.contentView addSubview:dayLabel];
[cell.contentView addSubview:monthLabel];
// ... and so on
}
else
{
// A reusable cell was available, so we just need to get
// a reference to the subviews using their tags
dayLabel = (UILabel *) [cell.contentView viewWithTag:kDayLabelTag];
monthLabel = (UILabel *) [cell.contentView viewWithTag:kMonthLabelTag];
}
NSArray *cellInfoArray = [self.dataSource objectAtIndex:indexPath.row];
dayLabel.text = [cellInfoArray objectAtIndex:0];
monthLabel.text = [cellInfoArray objectAtIndex:1];
return cell; How to create a custom cell programmatically in iOS](https://i.ytimg.com/vi/FTt7doXcYjc/mqdefault.jpg)






