0

我有一个视图(HomeView),我在其中打开了一个 popOver。popoVer 内容视图是 (ListView),其中包含一个表视图。

现在,当我选择该行时,HomeView 将关闭并打开一个新视图(MapView)。

到目前为止,它工作正常。但是我的所有视图都包含 xib 中的标签栏。我在 ListView 中没有标签栏。

所以,我只是用当前的模态视图打开 MapView。但是从那以后我的导航不起作用。

我的代码如下。

HomeView.m

//用ListView打开popview

-(IBAction)btnTableMenu_TouchUpInside:(id)sender{

ListView *popUp=[[ListView alloc] initWithNibName:@"ListView" bundle:nil];



    popView = [[UIPopoverController alloc]initWithContentViewController:popUp];
    popView.delegate =self;

    [popView setPopoverContentSize:CGSizeMake(300, 700)];
    [popView presentPopoverFromRect:CGRectMake(150,25,20,50) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

列表视图.m

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   [[NSNotificationCenter defaultCenter] postNotificationName:@"DismissModal"object:self];

    MapViewController *mapVC=[[MapViewController alloc]initWithNibName:@"MapViewController_ipad" bundle:nil];
    [self presentModalViewController:mapVC animated:YES];
    //[self.navigationController pushViewController:mapVC animated:YES];
}

我该如何解决这个问题?

4

3 回答 3

0

你只是这样做: -

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   [[NSNotificationCenter defaultCenter] postNotificationName:@"DismissModal"object:self];

    MapViewController *mapVC=[[MapViewController alloc]initWithNibName:@"MapViewController_ipad" bundle:nil]; 
    UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:mapVC];
    navbar.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];


    [navbar setModalPresentationStyle:UIModalPresentationFormSheet];
    [navbar setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];

    [self presentModalViewController:navbar animated:YES];

}

MapViewController.m文件中ViewDidLoad

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIBarButtonItem *CancleButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancel)];
    self.navigationItem.leftBarButtonItem = CancleButton;

}

-(void)cancel
{

    [self dismissModalViewControllerAnimated:YES];  

}
于 2013-01-17T12:47:15.927 回答
0

顺便说一句,你知道区别.. [self presentModalViewController:controller animated:YES]; &[self.navigationController pushViewController:controller animated:YES];

\当您执行 presentModalViewController:controller 时,您丢失了最后一个导航堆栈。您需要创建不同的导航控制器来呈现视图。正确阅读此内容,您将获得 Idea。

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html

于 2013-01-17T13:07:57.527 回答
0

尝试遵循这些-

列表视图.m

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   [[NSNotificationCenter defaultCenter] postNotificationName:@"DismissModal"object:self userInfo:[NSDictionary dictionaryWithObject:@"map" forKey:@"selectedView"]];
}

HomeView.m

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissModal:) name:@"DismissModal" object:nil];


- (void) dismissModal:(NSNotification *)notification
{
    [self dismissModalViewController:mapVC animated:NO];

    if([[notification.userInfo valueForKey:@"selectedView"] isEqualToString:@"map"])
    {
        MapViewController *mapVC=[[MapViewController alloc]initWithNibName:@"MapViewController_ipad" bundle:nil]; 
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mapVC];
        [self presentModalViewController:navController animated:YES];
    }
}
于 2013-01-17T13:56:34.473 回答