1

我的 iphone 应用程序出现了一个问题。我正在开发带有多个 detailview 控制器的 UISlitViewcontroller。一切正常,但我的一个 detailviewcontroller 想要在特定的 detailview 上推送更多的 viewcontroller。Pusp and pop 效果很好。虽然推送过渡动画效果很好,但弹出过渡无效。这是我下面的代码。请告诉我的问题的解决方案。

//在应用程序委托中我初始化我的splitviewcontroller...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    self.rootVC = [[MasterViewController1 alloc]init];
    self.detailVC = [[DetailViewController alloc]init];
    UINavigationController *DetailNav = [[UINavigationController alloc]initWithRootViewController:self.detailVC];

    SplitVC = [[UISplitViewController alloc]init];
    SplitVC.viewControllers = [[NSArray alloc]initWithObjects:self.rootVC, DetailNav, nil];
    SplitVC.delegate = self.detailVC;

    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.window.rootViewController = SplitVC;
    [self.window makeKeyAndVisible];
    return YES;
}

//在主视图中,我像这样使用多个视图控制器

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = indexPath.row;
    [self.appDelegate.SplitVC viewWillDisappear:YES];
    NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appDelegate.SplitVC.viewControllers objectAtIndex:1] viewControllers]];
    [viewControllerArray removeLastObject];


    if (row == 0) 
    {
        self.detailViewController = [[DetailViewController alloc] init];
        [viewControllerArray addObject:self.detailViewController];
        self.detailViewController.detailItem = self.detailViewController;
        self.appDelegate.SplitVC.delegate = self.detailViewController;
    }
    if (row == 1) 
    {
        self.currencyVC = [[CurrencyConvertorViewController alloc]init];
        [viewControllerArray addObject:self.currencyVC];
        self.currencyVC.detailItem = self.currencyVC;
        self.appDelegate.SplitVC.delegate = self.currencyVC;
    }

    if (row == 2) 
    {
        self.latest = [[PhoneExample alloc]init];
        [viewControllerArray addObject:self.latest];
        self.latest.detailItem = self.latest;
        self.appDelegate.SplitVC.delegate = self.latest;
    }

    if (row == 3) 
    {
        self.settingsVC = [[SettingPage alloc]init];
        [viewControllerArray addObject:self.settingsVC];
        self.settingsVC.detailItem = self.settingsVC;
        self.appDelegate.SplitVC.delegate = self.settingsVC;
    }
    [[self.appDelegate.SplitVC.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];    
    [self.appDelegate.SplitVC viewWillAppear:YES];
}

在我的一个详细视图控制器中,我在同一主选择的行视图控制器中推送另一个视图控制器,如下所示

-

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    LatestVersionMobileViewController *phone_version = [[LatestVersionMobileViewController alloc]init];
    phone_version.phone = [phone_types objectAtIndex:indexPath.row];
    self.title = @"Phones";
    [self.navigationController pushViewController:phone_version animated:YES];
}

然后像这样的UserOrientation..

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    // Overriden to allow any orientation.
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    {
[[self navigationItem] setLeftBarButtonItem:nil];

 CGRect frame1 = CGRectMake(0, 0, 700, 768);
        self.view.frame = frame1;
        frame1.size.width = frame1.size.width + 10;
        myTable.frame = frame1;
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    else 
    {
        [[self navigationItem] setLeftBarButtonItem:self.appDelegate.rootPopoverButtonItem];

        frame.origin.x = 0;
        frame.origin.y = 0;
        self.view.frame = frame;
        myTable.frame = frame;
        return interfaceOrientation == UIInterfaceOrientationPortrait;
    }   

}

4

0 回答 0