使用替换segue for iPad时的内存问题

时间:2012-02-17 09:24:04

标签: ipad ios5 uisplitviewcontroller

当我使用替换detailView segue应用程序崩溃时。

我正在更换一堆视图控制器,(第一个是导航控制器,然后是带视图控制器的tabBar控制器)。 tabBar Controller是splitViewController的委托。

错误信息是:

-[TabBarController splitViewController:shouldHideViewController:inOrientation:]: 
message sent to deallocated instance 0x9b7d180

Upd。:TabBarController代码

//  TabBarController.m
#import "TabBarController.h"

@implementation TabBarController
@synthesize masterPopoverController = _masterPopoverController;
#pragma mark - View lifecycle

- (void)awakeFromNib  // always try to be the split view's delegate
{
    [super awakeFromNib];
    self.splitViewController.delegate = self;
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.delegate = self;
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    self.splitViewController.delegate = nil;
    self.delegate = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

#pragma mark - Split view

- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
//    barButtonItem.title = NSLocalizedString(@"Master", @"Master");
//    [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
//    self.masterPopoverController = popoverController;
}

- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    // Called when the view is shown again in the split view, invalidating the button and popover controller.
//    [self.navigationItem setLeftBarButtonItem:nil animated:YES];
//    self.masterPopoverController = nil;
}
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
    return NO;
}
@end

1 个答案:

答案 0 :(得分:0)

问题是我将UISplitViewController的委托分配给了detailView。 重新启动detailView会导致内存问题。 在我创建AppDelegate之后,UISplitViewController问题的委托也解决了。