CorePlotDemo code is a demo program of CorePlot graph, pie chart, and columnar Statistical Chart library. Use xib as the UI
The procedure is as follows:
1. Delete the mainwindow. xib file first.
2. modify main. m
Main function:
# Import "CorePlotDemoAppDelegate. h" // introduce the header file
Int main (int argc, char * argv []) {
// NSAID utoreleasepool * pool = [[NSAID utoreleasepool alloc] init];
@ Autoreleasepool {
ReturnUIApplicationMain (argc, argv, nil, NSStringFromClass ([CorePlotDemoAppDelegateclass]);
}
// [Pool release];
}
3. Create a storyboard File
4. Set project properties to load from the storyboard File
Select Main Storyboard under "CorePlotDemo"-"Summary" to set the new storyboard file.
5. in the storyboard file, create a tabBarController container, and create three new viewcontrollers, tabBarController, and three viewcontrollers (right-click control, and draw lines to each viewController. Select the first option in the pop-up menu ), set the identifier attribute of tabBarController to tabBarController.
6. Three viewcontrollers (rootViewController, pieChartViewController, and barChartViewController) are associated with the class file (RootViewController, PieChartViewController, BarChartViewController)
7. After the association is established, modify the code and control the display of three vewcontrollers from the code.
Modify the source code file CorePlotDemoAppDelegate. m.
7.1 modify as follows, and the code between the following/**/remains unchanged
/* The intermediate code remains unchanged at www.2cto.com.
// 1. initialize rootViewController
Self. rootViewController = [[RootViewController alloc] init] autorelease];
// 2. Construct the controllers View
BarChartViewController * barChart = [[BarChartViewControlleralloc] init];
PieChartViewController * pieChart = [[PieChartViewControlleralloc] init];
NSArray * controllers = [[NSArrayalloc] initWithObjects: self. rootViewController, barChart, pieChart, nil];
[BarChartrelease];
[PieChartrelease];
// 3. Set entries on the tabBar
UITabBarItem * tabBarItemOne = [[UITabBarItemalloc] initWithTitle: @ "Scatter" image: nil tag: 0];
UITabBarItem * tabBarItemTwo = [[UITabBarItemalloc] initWithTitle: @ "Pie" image: nil tag: 1];
UITabBarItem * tabBarItemThree = [[UITabBarItemalloc] initWithTitle: @ "Bar" image: nil tag: 2];
*/
7.1.1 comment the following line
// TabBarController = [[UITabBarController alloc] init]; // we have drawn UITabBarController on the storyboard.
7.1.2 Add the following code for Modification
NSString * tbControllerId = @ "tabBarController ";
UIStoryboard * sb = [UIStoryboardstoryboardWithName: @ "baStoryboard" bundle: nil]; // get the storyboard object pointer
UITabBarController * tbController = [sbinstantiateViewControllerWithIdentifier: tbControllerId]; // obtain tabbarcontroller
TbController. viewControllers = controllers;
[[TbController. viewControllersobjectAtIndex: 0] setTabBarItem: tabBarItemOne];
[[TbController. viewControllersobjectAtIndex: 1] setTabBarItem: tabBarItemTwo];
[[TbController. viewControllersobjectAtIndex: 2] setTabBarItem: tabBarItemThree];
At this time, three viewcontrollers have been set in tabBarController of storyboard. Run the command to display the view in tabBarController.
From gaoxuefeng's column