Select a city, and then go to the page where tabbar is located (like a new house in ankeju). Select the city tabbar
Homepage display:
When you click a cell:
File directory:
ChooseCityViewController. h
#import <UIKit/UIKit.h>@interface ChooseCityViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{ NSMutableArray * dataArray; UITableView * mTableView;}@end
ChooseCityViewController. m
-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // read the plist file [self readPlistFile]; // initialize tableView [self initTableView];} # pragma-mark-functions-(void) readPlistFile {dataArray = [[NSMutableArray alloc] initWithCapacity: 0]; NSString * path = [[NSBundle mainBundle] pathForResource: @ "city" ofType: @ "plist"]; NSDictionary * dict = [[NSDictionary alloc] handler: path]; NSEnumerator * enumerator = [dict keyEnumerator]; NSString * key; while (key = [enumerator nextObject]) {NSDictionary * t = [dict objectForKey: key]; [dataArray addObject: t];} NSLog (@ "% @", dataArray);}-(void) initTableView {mTableView = [[UITableView alloc] initWithFrame: self. view. bounds style: UITableViewStylePlain]; mTableView. delegate = self; mTableView. dataSource = self; mTableView. autoresizingMask = UIViewAutoresizingFlexibleHeight; [self. view addSubview: mTableView] ;}# pragma-UITableViewDelegate-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {return [dataArray count];}-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {static NSString * ID = @ "cellID"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: ID]; if (cell = nil) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: ID];} NSDictionary * dict = [dataArray objectAtIndex: indexPath. row]; cell. textLabel. text = [dict objectForKey: @ "city_name"]; return cell;}-(void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath {NSDictionary * dict = [dataArray objectAtIndex: indexPath. row]; // Save the selected city to the local [[NSUserDefaults standardUserDefaults] setObject: [dict objectForKey: @ "city_id"] forKey: @ "city_id"]; [[NSUserDefaults standardUserDefaults] setObject: [dict objectForKey: @ "city_name"] forKey: @ "city_name"]; // jump to another page with tabbar: DetailViewController * detail = [[DetailViewController alloc] init]; [self. navigationController pushViewController: detail animated: NO];}
DetailViewController. m
-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // background color self. view. backgroundColor = [UIColor redColor]; // The navigation bar does not hide self. navigationController. navigationBarHidden = NO; // The toolbar does not hide self. navigationController. toolbarHidden = NO ;}
How can I jump to the tabBarViewController page during iphone development?
Just add the tabbar control to the viewdiload Method on that page.