如何将一个函数中的一个变量的内存感知到另一个函数

时间:2013-04-01 13:24:07

标签: ios objective-c uisplitviewcontroller ipad

- (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是全局变量。

0 个答案:

没有答案