Navigation Controller
// Create a navigation Controller
BIDRootViewController * pRootVC = [[BIDRootViewController alloc] initWithNibName: nil bundle: nil];
Self. mRootVC = pRootVC;
[PRootVC release];
UINavigationController * pNav = [[UINavigationController alloc] initWithRootViewController: self. mRootVC];
Self. window. rootViewController = pNav;
Name
Self. navigationItem. title = @ "Root View ";
Create an attempt for the title
UIView * pTitleView = [[UIView alloc] initWithFrame: CGRectMake (0, 0,160, 44)];
[PTitleView setBackgroundColor: [UIColor redColor];
Self. navigationItem. titleView = pTitleView;
Create a barItem
UIBarButtonItem * pBar = [[UIBarButtonItem alloc] initWithTitle: @ "NextVC" style: UIBarButtonItemStylePlain target: self action: @ selector (goToNextVC :)];
Self. navigationItem. rightBarButtonItem = pBar;
BarItem call Method
-(Void) goToNextVC :( id) sender {
BIDNextViewController * pNextVC = [[BIDNextViewController alloc] initWithNibName: nil bundle: nil];
[Self. navigationController pushViewController: pNextVC animated: YES];
}
TableBar --- label bar
Create tag bar
BIDViewController * pViewController = [[BIDViewController alloc] initWithNibName: nil bundle: nil];
UITabBarController * pTapBarVC = [[UITabBarController alloc] init];
PTapBarVC. viewControllers = [NSArray arrayWithObjects: pViewController, nil];
Use system resources to name tags
Self. window. rootViewController = pTapBarVC;
Self. tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemFavorites tag: 111];
Add badgeValue in the upper right corner
Self. tabBarItem. badgeValue = @ "1 ";
Custom name
Self. tabBarItem = [[UITabBarItem alloc] initWithTitle: @ "second" image: nil tag: 122];
Table View
Create
The. h file must include:
@ Property (retain, nonatomic) UITableView * mTableView;
// Store table data
@ Property (retain, nonatomic) NSArray * mArr;
It also complies with the UITableViewDataSource and UITableViewDelegate protocols.
Self. mArr = [UIFont familyNames];
// Create an initialization table View
Self. mTableView = [[UITableView alloc] initWithFrame: self. view. frame style: UITableViewStylePlain];
UIView * pView = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320, 50)];
PView. backgroundColor = [UIColor blueColor];
Self. mTableView. tableHeaderView = pView;
// Set the header height
Self. mTableView. sectionHeaderHeight = 50;
// Set the delegate object
Self. mTableView. dataSource = self;
Self. mTableView. delegate = self;
// Add to view
[Self. view addSubview: self. mTableView];
# Pragma mark --- tableView DataSource ----
// Number of rows in each segment
-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section
{
Return [self. mArr count];
}
// Draw each row
-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath
{
Static NSString * identifer = @ "identfier ";
UITableViewCell * pCell = [tableView dequeueReusableCellWithIdentifier: identifer];
If (nil = pCell)
{
PCell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: identifer];
}
// Obtain the current row
NSUInteger cellRow = [indexPath row];
// Locate the data corresponding to the lower mark in the array based on the number of rows
NSString * pTempStr = [self. mArr objectAtIndex: cellRow];
// Set text content
PCell. textLabel. text = pTempStr;
// Set the text font
PCell. textLabel. font = [UIFont fontWithName: pTempStr size: 18];
PCell. detailTextLabel. text = @ "detailText ";
// Add an image to the left
PCell. imageView. image = [UIImage imageNamed: @ "Default-568h @ 2x"];
PCell. accessoryType = UITableViewCellAccessoryCheckmark;
Return pCell;
}
// Create a header
-(NSString *) tableView :( UITableView *) tableView titleForHeaderInSection :( NSInteger) section
{
Return @ "I'm Header_Title ";
}
// Create the end of the table
-(NSString *) tableView :( UITableView *) tableView titleForFooterInSection :( NSInteger) section
{
Return @ "I'm Footer_Title ";
}
# Pragma mark --- table delegate -----
// Select a row and call
-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath
{
NSUInteger row = [indexPath row];
NSString * pStr = [NSString stringWithFormat: @ "you selected row % d", row];
// Modal View
UIActionSheet * pActionSheet = [[UIActionSheet alloc] initWithTitle: @ "ActionSheet" delegate: self cancelButtonTitle: @ "OK" destructiveButtonTitle: pStr failed: nil, nil];
[PActionSheet showInView: self. view];
// Gradually fade out the selected row
[Self. mTableView deselectRowAtIndexPath: indexPath animated: YES];
}
// Adjust the Row Height
-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath
{
Return 44;
}
// Adjust the header height
-(CGFloat) tableView :( UITableView *) tableView heightForHeaderInSection :( NSInteger) section
{
Return 20;
}
// Offset the row content
-(NSInteger) tableView :( UITableView *) tableView indentationLevelForRowAtIndexPath :( NSIndexPath *) indexPath
{
Return 0;
}