Select a city, and then go to the page where tabbar is located (like a new house in ankeju). Select the city tabbar

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.