TransitionFromView崩溃 - iphone

时间:2014-01-25 12:06:42

标签: iphone objective-c transition

在我的应用程序中,我有一个表视图中的项目列表。点击其中一个,该应用程序显示该项目的详细信息。细节显示,并通过导航控制器的后退按钮,应用程序返回列表。

在详细视图中,我实现了一种滑动手势的方法,以便将视图更改为列表的第二个元素的详细信息,依此类推。为了做到这一点,我在oneFingerSwipeLeft方法中使用“transitionFromView”。 aidea将重用相同的视图,其中只有内部信息发生变化。

更改视图的方法是:

- (void)oneFingerSwipeLeft:(UITapGestureRecognizer *)recognizer {
    int idx=currentIdx;
    if (idx ==[todasLasTapas count]-1) {   //last object vuelvo al primero
        idx= -1;
    }
    ClassInfo *info =[allInfo objectAtIndex:idx+1];
    //VIEW CONTROLLER
    MoreInfo *moreInfoController =[[MoreInfo alloc]initWithNibName:@"MoreInfoController" bundle:nil];

    //passing the details to view
    moreInfoController.id = info.uniqueId;
    moreInfoController.name = info.name;
    [UIView transitionFromView:self.view
                       toView:moreInfoController.view
                       duration:1
                       options:UIViewAnimationOptionTransitionCrossDissolve 
                       completion:^(BOOL finished) {
                             [self.view removeFromSuperview];
                    }];
}

它可以工作,但只能在第一个滑动手指上。在第二次滑动应用程序崩溃时,仅显示(lldb)输出消息。

当我尝试通过手指滑动为“第三”视图充电时发生了崩溃。但是,尝试使用NSLOG进行调试时,代码不会再次进入方法

-(void)oneFingerSwipeLeft:(UITapGestureRecognizer *)recognizer

lldb bt响应是:

(lldb) bt
* thread #1: tid = 0x1f03, 0x0187b09b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=2, address=0x8)
    frame #0: 0x0187b09b libobjc.A.dylib`objc_msgSend + 15
    frame #1: 0x00a7885a UIKit`_UIGestureRecognizerSendActions + 139
    frame #2: 0x00a7799b UIKit`-[UIGestureRecognizer _updateGestureWithEvent:] + 333
    frame #3: 0x00a790df UIKit`-[UIGestureRecognizer _delayedUpdateGesture] + 46
    frame #4: 0x00a7bd2d UIKit`___UIGestureRecognizerUpdate_block_invoke_0543 + 57
    frame #5: 0x00a7bcac UIKit`_UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 331
    frame #6: 0x00a73a28 UIKit`_UIGestureRecognizerUpdate + 1348
    frame #7: 0x007e0972 UIKit`-[UIWindow _sendGesturesForEvent:] + 1283
    frame #8: 0x007e0e53 UIKit`-[UIWindow sendEvent:] + 98
    frame #9: 0x007bed4a UIKit`-[UIApplication sendEvent:] + 436
    frame #10: 0x007b0698 UIKit`_UIApplicationHandleEvent + 9874
    frame #11: 0x026eadf9 GraphicsServices`_PurpleEventCallback + 339
    frame #12: 0x026eaad0 GraphicsServices`PurpleEventCallback + 46
    frame #13: 0x019b9bf5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    frame #14: 0x019b9962 CoreFoundation`__CFRunLoopDoSource1 + 146
    frame #15: 0x019eabb6 CoreFoundation`__CFRunLoopRun + 2118
    frame #16: 0x019e9f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #17: 0x019e9e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #18: 0x026e97e3 GraphicsServices`GSEventRunModal + 88
    frame #19: 0x026e9668 GraphicsServices`GSEventRun + 104
    frame #20: 0x007adffc UIKit`UIApplicationMain + 1211
    frame #21: 0x000184fd pruebasTapas`main(argc=1, argv=0xbffff2e0) + 141 at main.m:16
(lldb) 

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

尝试简单的事情

-(void) viewDidLoad
{
   UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swiped)];
   swipe.direction = UISwipeGestureRecognizerDirectionLeft;
   //rest of the code
}


-(void) swiped
{
    [self viewWillAppear:YES];
}

使用viewWillAppear

中的数据重新加载视图