简体   繁体   中英

iOS app crashed when enter text in UiWebView

In my iOS(Objective C) app, I am loading a UIWebView in a UIView and it just lead to the App crash when I click on a Text field in the webview, say in Google if I just touch the text field to enter some keyword the app will crash. I am able to open the webView in sample app, but it fails in my project.

I have user the strong reference for the variables. Error is:

-[__NSCFSet keyboardWillShow:]: unrecognized selector sent to instance 0x8fa0140
2014-08-25 12:15:40.626 Travelara[1263:60b] *** Terminating app due to uncaught exception            'NSInvalidArgumentException', reason: '-[__NSCFSet keyboardWillShow:]: unrecognized selector    sent to instance 0x8fa0140'
*** First throw call stack:
(
0   CoreFoundation                      0x01c7a1e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x019778e5 objc_exception_throw + 44
2   CoreFoundation                      0x01d17243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3   CoreFoundation                      0x01c6a50b ___forwarding___ + 1019
4   CoreFoundation                      0x01c6a0ee _CF_forwarding_prep_0 + 14
5   Foundation                          0x0164a049 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
6   CoreFoundation                      0x01cd5f04 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
7   CoreFoundation                      0x01c2defb _CFXNotificationPost + 2859
8   Foundation                          0x01583e41 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
9   UIKit                               0x00af1625 -[UIInputViewTransition postNotificationsForTransitionStart] + 1004
10  UIKit                               0x00ae7562 -[UIPeripheralHost(UIKitInternal) executeTransition:] + 592
11  UIKit                               0x00ae9a79 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 929
12  UIKit                               0x00ae9e7e -[UIPeripheralHost(UIKitInternal) setInputViews:animated:] + 72
13  UIKit                               0x00ae9ec8 -[UIPeripheralHost(UIKitInternal) setInputViews:] + 67
14  UIKit                               0x00ae0fb1 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1448
15  UIKit                               0x0079d8b4 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 287
16  UIKit                               0x00b0a6b5 -[UIWebBrowserView assistFormNode:] + 265
17  UIKit                               0x0087e435 __47-[UIWebDocumentView(Interaction) performClick:]_block_invoke172 + 52
18  libdispatch.dylib                   0x02e784d0 _dispatch_client_callout + 14
19  libdispatch.dylib                   0x02e67439 _dispatch_barrier_sync_f_slow_invoke + 80
20  libdispatch.dylib                   0x02e784d0 _dispatch_client_callout + 14
21  libdispatch.dylib                   0x02e66726 _dispatch_main_queue_callback_4CF + 340
22  CoreFoundation                      0x01cdf43e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
23  CoreFoundation                      0x01c205cb __CFRunLoopRun + 1963
24  CoreFoundation                      0x01c1f9d3 CFRunLoopRunSpecific + 467
25  CoreFoundation                      0x01c1f7eb CFRunLoopRunInMode + 123
26  GraphicsServices                    0x034145ee GSEventRunModal + 192
27  GraphicsServices                    0x0341442b GSEventRun + 104
28  UIKit                               0x00637f9b UIApplicationMain + 1225
29  Travelara                           0x0007b34d main + 141
30  libdyld.dylib                       0x030ad701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

The code I am using is: self.webview1=[[UIWebView alloc]initWithFrame:CGRectMake (10,70,292,430)];

    self.webview1.backgroundColor= [UIColor whiteColor]; 
    self.webview1.userInteractionEnabled=true;
    self.webview1.multipleTouchEnabled=true;
    self.webview1.delegate=self;
   [self addSubview:self.webview1];

     self.url=@"https://www.google.co.in/";
    self.nsurl=[NSURL URLWithString:self.url];
    self.nsrequest=[NSURLRequest requestWithURL:self.nsurl];
    [self.webview1 loadRequest:self.nsrequest];

Please help me to solve the issue.

although the source code is not enough to make accurate guess but looks like you defined something like

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(keyboardWillShow:) 
    name:UIKeyboardWillShowNotification object:nil];

to get event event notification about keyboard display but forgot to define the functions

- (void)keyboardWillShow:(NSNotification *)aNotification {
    [self performSelector:@selector(readjustWebviewScroller) withObject:nil afterDelay:0];
}

Please check.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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