开发者

TableView within NavigationBar within TabBar Navigation?

开发者 https://www.devze.com 2023-02-07 14:44 出处:网络
I am building an app with several levels. First level are the Tabs on the bottom of the screen. (MainWindow)

I am building an app with several levels.

  • First level are the Tabs on the bottom of the screen. (MainWindow)

  • Second Level is the content displayed with each tab in a TableView (Locations)

  • Third Level is the detailed overview of the selected item in the Second level content. (LocationDetails)

First and Second levels work fine. Now I want to create the开发者_开发百科 content of the detailled overview. I have created a new NIB called LocationDetails.xib. It only contains some static text (an inserted Text View). So I can view the loaded window.

In the Locations.m file I have the following function:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString * locationCity = [[locations objectAtIndex:indexPath.row] objectForKey:@"city"];

NSLog(@"Your choice is: %@", locationCity);

Within this function I want to go to an other view (LocationDetails). What is the best way to go. If I haven't given you enough information, tell me! I can provide all the information you need!

Hope to hear from you soon!

With kind regards,

Douwe


I would use a navigation controller.

In your main xib file you would end up with something like this :

UITabBarViewController // Main Window
  tab 1:
    UINavigationController
      UITableView // (Locations)

  tab 2:
    UINavigationController
      UITableView // (Locations)

Then, the code to slide on your LocatonDetails is simple :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    LocationDetailsViewController = [[LocationDetailsViewController alloc] initWithNibName:@"LocationDetails" bundle:nil];
    controller setLocation:[locations objectAtIndex:indexPath.row]];
    [[self navigationController] pushViewController:controller animated:YES];
    [controller release];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消