简体   繁体   English

iOS 7应用在UITextField输入上崩溃

[英]iOS 7 app crashes on UITextField input

I'm trying to develop a questionnaire app where sometimes, a string must be inputted. 我正在尝试开发一个调查表应用程序,有时必须输入一个字符串。 In interface builder I have a scroll view, and in it a UITextField. 在界面生成器中,我有一个滚动视图,在其中有一个UITextField。 But when I run it in the simulator, the app crashes when I try to input a simple string into it. 但是,当我在模拟器中运行它时,当我尝试向其中输入简单的字符串时,应用程序将崩溃。 The keyboard shows up, but as soon as I try to type something, I get a SIGARBT on the main function. 键盘出现了,但是当我尝试键入内容时,我在主要功能上得到了SIGARBT。 The complete error message (don't mind the app name, it's just a simple test app that I made in a few minutes): 完整的错误消息(不要介意应用程序名称,它只是我在几分钟内制作的简单测试应用程序):

2014-03-08 18:16:38.564 hetisweertijdvoordepolonaise[4381:70b] -[NSNull length]: unrecognized selector sent to instance 0x1898068
2014-03-08 18:16:38.569 hetisweertijdvoordepolonaise[4381:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1898068'
*** First throw call stack:
(
    0   CoreFoundation                      0x0174c5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014bb8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x017e9903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x0173c90b ___forwarding___ + 1019
    4   CoreFoundation                      0x0173c4ee _CF_forwarding_prep_0 + 14
    5   CoreFoundation                      0x016cc95c CFStringGetLength + 140
    6   CoreFoundation                      0x016e0284 CFStringCompareWithOptionsAndLocale + 52
    7   Foundation                          0x010c6634 -[NSString compare:options:range:locale:] + 175
    8   Foundation                          0x010c6580 -[NSString compare:options:range:] + 69
    9   Foundation                          0x010d8a59 -[NSString caseInsensitiveCompare:] + 80
    10  UIKit                               0x0043ff48 -[UIPhysicalKeyboardEvent _matchesKeyCommand:] + 280
    11  UIKit                               0x00383ac9 -[UIResponder(Internal) _keyCommandForEvent:] + 312
    12  UIKit                               0x00383b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
    13  UIKit                               0x00383b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
    14  UIKit                               0x00383b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
    15  UIKit                               0x00383b3b -[UIResponder(Internal) _keyCommandForEvent:] + 426
    16  UIKit                               0x0023d34b -[UIApplication _handleKeyUIEvent:] + 138
    17  UIKit                               0x00383fa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
    18  UIKit                               0x00383fa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
    19  UIKit                               0x00383fa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
    20  UIKit                               0x00383fa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
    21  UIKit                               0x00383fa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
    22  UIKit                               0x00383fa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
    23  UIKit                               0x0023d2ba -[UIApplication handleKeyUIEvent:] + 84
    24  UIKit                               0x00413d29 -[UIKeyboardImpl _handleKeyEvent:executionContext:] + 80
    25  UIKit                               0x0058d179 -[UIKeyboardLayoutStar completeRetestForTouchUp:timestamp:interval:executionContext:] + 4078
    26  UIKit                               0x0058bc7f -[UIKeyboardLayoutStar touchUp:executionContext:] + 1545
    27  UIKit                               0x00421f18 __28-[UIKeyboardLayout touchUp:]_block_invoke + 269
    28  UIKit                               0x009383c8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 402
    29  UIKit                               0x00938a6f -[UIKeyboardTaskQueue addTask:] + 144
    30  UIKit                               0x00421e03 -[UIKeyboardLayout touchUp:] + 263
    31  UIKit                               0x00422939 -[UIKeyboardLayout touchesEnded:withEvent:] + 362
    32  UIKit                               0x0026851d -[UIWindow _sendTouchesForEvent:] + 852
    33  UIKit                               0x00269184 -[UIWindow sendEvent:] + 1232
    34  UIKit                               0x0023ce86 -[UIApplication sendEvent:] + 242
    35  UIKit                               0x0022718f _UIApplicationHandleEventQueue + 11421
    36  CoreFoundation                      0x016d583f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    37  CoreFoundation                      0x016d51cb __CFRunLoopDoSources0 + 235
    38  CoreFoundation                      0x016f229e __CFRunLoopRun + 910
    39  CoreFoundation                      0x016f1ac3 CFRunLoopRunSpecific + 467
    40  CoreFoundation                      0x016f18db CFRunLoopRunInMode + 123
    41  GraphicsServices                    0x036dd9e2 GSEventRunModal + 192
    42  GraphicsServices                    0x036dd809 GSEventRun + 104
    43  UIKit                               0x00229d3b UIApplicationMain + 1225
    44  hetisweertijdvoordepolonaise        0x0000204d main + 141
    45  libdyld.dylib                       0x01d76701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

ViewController.m: ViewController.m:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end

Is there some fundamental thing I forgot? 我有一些基本的东西忘了吗?

According to the stack trace, maybe you have initialized a NSString incorrectly. 根据堆栈跟踪,可能您未正确初始化NSString。 Please paste the relevant code. 请粘贴相关代码。

This is a shot in the dark without seeing more of your code. 这是一个黑暗的镜头,却看不到更多代码。 Looking at the stacktrace, it seems like your code is misinterpreting your text input as a key command for some reason. 查看stacktrace,由于某种原因,您的代码似乎误将文本输入解释为键盘命令。 It is trying to compare your input against a set of known commands and failing. 它试图将您的输入与一组已知命令进行比较,但失败了。

There are a few other things that might be related since you are running in the simulator. 由于您正在模拟器中运行,因此可能还有其他一些相关事项。 In the 'hardware' menu is 'simulate hardware keyboard' checked? 在“硬件”菜单中是否选中了“模拟硬件键盘”? What about 'IOS uses same layout as OSX'? 那么“ IOS使用与OSX相同的布局”呢?

One last thing. 最后一件事。 If you really want people to be able to reproduce this issue, we need to see the UI code. 如果您确实希望人们能够重现此问题,则需要查看UI代码。 If you right click on your storyboard file and select 'open as' there is an option to view the file as source code. 如果右键单击情节提要文件,然后选择“打开为”,则可以选择以源代码形式查看该文件。 For an app as simple as what you described, the text should be small enough that you can paste it here or host it somewhere and provide a link. 对于您所描述的简单的应用程序,文本应足够小,以至于您可以将其粘贴在此处或托管在某处并提供链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM