按切换按钮切换容器视图时,应用程序崩溃

时间:2013-06-18 04:41:34

标签: ios objective-c crash container-view

我的应用中有一个按钮可以切换容器视图,从tableview到Google地图视图。

交换机工作大约4次,然后当我再次尝试切换容器视图时,应用程序崩溃,我收到以下错误:

(71189,0xac12f2c0) malloc: *** mmap(size=1492946944) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
2013-06-17 21:37:28.876 Vicinitime[71189:12e03] *** Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableViewRowData.m:400
2013-06-17 21:37:28.876 Vicinitime[71189:12e03] *** Terminating app due to uncaught   exception 'NSInternalInconsistencyException', reason: 'Failed to allocate data stores for 373235904 rows in section 0. Consider using fewer rows'
*** First throw call stack:
(0x258b012 0x23b0e7e 0x258ae78 0x1e46665 0x14d969b 0x14dc224 0x13a0952 0x13a02dc 0x13a3dd6     0x13a8a7e 0x13452dd 0x23c46b0 0x533fc0 0x52833c 0x528150 0x4a60bc 0x4a7227 0x549b50 0x130aedf 0x2553afe 0x2553a3d 0x25317c2 0x2530f44 0x2530e1b 0x30617e3 0x3061668 0x12f4ffc 0x24fd 0x2425)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

以下是切换容器的代码。对于凌乱的代码感到抱歉,但viewcontroller2实际上是一个tableview,只是错误地命名。 det是BOOL

-(IBAction)changer:(id)sender
{

    if(det == TRUE)
    {
        test *viewController2 = [[test alloc]init];
        viewController2.view.frame = self.container.bounds;

        [viewController2 willMoveToParentViewController:self];
        [self.container addSubview:viewController2.view];
        [self addChildViewController:viewController2];
        [viewController2 didMoveToParentViewController:self];

        [UIView beginAnimations:nil context:nil];

        [UIView setAnimationDuration:1];

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft  forView:self.container cache:YES];

        [UIView commitAnimations];

        det = FALSE;
    }
    else
    {
        ViewController *viewController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc1"];
        viewController1.view.frame = self.container.bounds;

        [viewController1 willMoveToParentViewController:self];
        [self.container addSubview:viewController1.view];
        [self addChildViewController:viewController1];
        [viewController1 didMoveToParentViewController:self];
        [UIView beginAnimations:nil context:nil];

        [UIView setAnimationDuration:1];

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight  forView:self.container cache:YES];

        [UIView commitAnimations];

        det = TRUE;

    }
}

知道发生了什么事吗?

0 个答案:

没有答案
相关问题