0

当我单击我的 rightNavButton 以尝试打开一个新窗口时,我收到一个 NSException。但是,当我这样做时,它会突然退出模拟器并给我一个 NSException 错误。我已经对该主题进行了研究,但没有遇到同样的问题。我试图打开的 js 文件中没有任何错误,这是我不断收到的错误:

{[ERROR] The application has crashed with an unhandled exception. Stack trace:
0   CoreFoundation                      0x0238c58c __exceptionPreprocess + 156
1   libobjc.A.dylib                     0x024e0313 objc_exception_throw + 44
2   CoreFoundation                      0x02344ef8 +[NSException raise:format:arguments:] + 136
3   Foundation                          0x007313bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4   UIKit                               0x00be51d6 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 290
5   UIKit                               0x009ea65d -[UIViewController presentModalViewController:withTransition:] + 3478
6   DiscountShelving                    0x00198716 -[TiApp attachModal:toController:animated:] + 166
7   DiscountShelving                    0x00198751 -[TiApp attachModal:toController:animated:] + 225
8   DiscountShelving                    0x0019865a -[TiApp showModalController:animated:] + 474
9   DiscountShelving                    0x00063172 -[TiWindowProxy openOnUIThread:] + 2978
10  Foundation                          0x006b594e __NSThreadPerformPerform + 251
11  CoreFoundation                      0x0236d8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
12  CoreFoundation                      0x022cb88b __CFRunLoopDoSources0 + 571
13  CoreFoundation                      0x022cad86 __CFRunLoopRun + 470
14  CoreFoundation                      0x022ca840 CFRunLoopRunSpecific + 208
15  CoreFoundation                      0x022ca761 CFRunLoopRunInMode + 97
16  GraphicsServices                    0x041921c4 GSEventRunModal + 217
17  GraphicsServices                    0x04192289 GSEventRun + 115
18  UIKit                               0x00944c93 UIApplicationMain + 1160
19  DiscountShelving                    0x000045da main + 410
20  DiscountShelving                    0x00002ea5 start + 53
2012-05-30 14:58:46.035 DiscountShelving[19335:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <UINavigationController: 0x6d39e90> to <UINavigationController: 0x6d438d0> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0238c5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x024e0313 objc_exception_throw + 44
    2   CoreFoundation                      0x02344ef8 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x007313bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x00be51d6 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 290
    5   UIKit                               0x009ea65d -[UIViewController presentModalViewController:withTransition:] + 3478
    6   DiscountShelving                    0x00198716 -[TiApp attachModal:toController:animated:] + 166
    7   DiscountShelving                    0x00198751 -[TiApp attachModal:toController:animated:] + 225
    8   DiscountShelving                    0x0019865a -[TiApp showModalController:animated:] + 474
    9   DiscountShelving                    0x00063172 -[TiWindowProxy openOnUIThread:] + 2978
    10  Foundation                          0x006b594e __NSThreadPerformPerform + 251
    11  CoreFoundation                      0x0236d8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    12  CoreFoundation                      0x022cb88b __CFRunLoopDoSources0 + 571
    13  CoreFoundation                      0x022cad86 __CFRunLoopRun + 470
    14  CoreFoundation                      0x022ca840 CFRunLoopRunSpecific + 208
    15  CoreFoundation                      0x022ca761 CFRunLoopRunInMode + 97
    16  GraphicsServices                    0x041921c4 GSEventRunModal + 217
    17  GraphicsServices                    0x04192289 GSEventRun + 115
    18  UIKit                               0x00944c93 UIApplicationMain + 1160
    19  DiscountShelving                    0x000045da main + 410
    20  DiscountShelving                    0x00002ea5 start + 53
)
terminate called after throwing an instance of 'NSException'
[INFO] Application has exited from Simulator}

var btnCart = Titanium.UI.createButton({
title:'Cart'
});

btnCart.addEventListener('click', function(e){
var cartWin = Titanium.UI.createWindow({
    url:'../MainWindows/shoppingCart.js',
    barColor:'12235b',
    opacity: 1,
    zIndex: 1
});
cartWin.open({modal:true});
})

win.rightNavButton = btnCart;

如果有人知道这个问题或过去曾遇到过这个问题并已解决,请尽快告诉我!

谢谢

4

1 回答 1

0

我在我的应用程序中遇到了类似的崩溃。

我刚刚实现了一个睡眠方法,例如:

function sleep(milliseconds)
{
    var start = new Date().getTime();

    while((new Date().getTime() - start) < milliseconds)
    {
        // Do nothing
    }
}

并在打开窗口之前调用它,例如:

sleep(1000);
myWin.open();
于 2012-12-29T11:34:42.030 回答