0
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(WEPopoverController *)popoverController
{
          NSLog(@"inside split rotate");
    barButtonItem.title = NSLocalizedString(@"Master", @"Master");

    [[[[self.splitViewController.viewControllers objectAtIndex:1]topViewController]navigationItem ] setLeftBarButtonItem:barButtonItem animated:YES];

   // leftButtonItem=[[UIBarButtonItem alloc] init];

   leftButtonItem=barButtonItem;

     self.navigationItem.rightBarButtonItem.tintColor=[UIColor blackColor];
    self.navigationItem.leftBarButtonItem.tintColor=[UIColor blackColor];
    NSLog(@" bar buttn item =%@", barButtonItem);

    self.masterPopoverController = popoverController;
     NSLog(@" left buttn item =%@", leftButtonItem);
}


-(void)willRotateToInterfaceOrientation:  (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    NSLog(@"\n INSIDE ORENATATION METHOD");
    NSString *nib=[self nibName];

    if ([nib isEqualToString:@"toDoTaskListAppDetailViewController_iPhone"])
    {

    }
    else if ([nib isEqualToString:@"toDoTaskListAppDetailViewController_iPad"])
    {
        if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
        {
            //leftButtonItem=[[UIBarButtonItem alloc] init];


             NSLog(@"%@",leftButtonItem);
              self.navigationItem.leftBarButtonItem=leftButtonItem;

             //self.imageView.frame=CGRectMake(0.0,0.0, self.view.frame.size.width, self.view.frame.size.height);
                  }
        else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft)
        {
            //leftButtonItem=[[UIBarButtonItem alloc] init];


             NSLog(@"%@",leftButtonItem);
            leftButtonItem=self.navigationItem.leftBarButtonItem;
                       self.navigationItem.leftBarButtonItem=nil;
            // self.imageView.frame=CGRectMake(0.0,0.0, self.view.frame.size.width, self.view.frame.size.height);
        }
        else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight)
        {
            NSLog(@"%@",leftButtonItem);


           // leftButtonItem=[[UIBarButtonItem alloc] init];
           leftButtonItem=self.navigationItem.leftBarButtonItem;

            self.navigationItem.leftBarButtonItem=nil;
             //self.imageView.frame=CGRectMake(0.0,0.0, self.view.frame.size.width, self.view.frame.size.height);
        }
        else
        {
            //leftButtonItem=[[UIBarButtonItem alloc] init];


           NSLog(@"%@",leftButtonItem);

             self.navigationItem.leftBarButtonItem=leftButtonItem;

        }

    }

}

在 splitViewController 函数中,分配给 leftButtonItem 的内存不会感知 willRotateToInterfaceOrientation 中的内存。leftButtonItem 是全局变量。

4

0 回答 0