UIWebView not showing website - ios

I have created some simple code designed to show a webpage, which has been working perfectly fine since I created it. However, when I now run the app, the UIWebView no longer displays the webpage, although the NSLog shows the code is definitely being run.
In the .h: #property (weak, nonatomic) IBOutlet UIWebView *webView;
In the .m:
#synthesize webView;
- (void)viewDidLoad {
NSString *url = #"http://www.google.com";
[self createWebpage:url];
self.addressBar.delegate = self;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void) createWebpage:(NSString *)webString {
NSURL *url = [NSURL URLWithString:webString];
NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestUrl];
NSLog(#"Webpage is created!");
}
I recently (accidentally) deleted a Referencing Outlet between the back and forward UIButtons I had created. I say this in case it has anything to do with the problem. All help appreciated.
EDIT: I don't know why, but the app now does not load. It goes to the splash screen, and then errors, producing the error log below.
2014-09-21 14:19:14.273 Fullscreen Ninja Browser for iPhone 6[6673:349224] Webpage is created!
2014-09-21 14:19:14.278 Fullscreen Ninja Browser for iPhone 6[6673:349224] *** Assertion failure in -[NSLayoutConstraint constant], /SourceCache/Foundation_Sim/Foundation-1140.11/Layout.subproj/NSLayoutConstraint.m:643
2014-09-21 14:19:14.283 Fullscreen Ninja Browser for iPhone 6[6673:349224] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '(null)'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105a073f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001056a0bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105a0725a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001052be28f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 Foundation 0x000000010523a18d -[NSLayoutConstraint constant] + 170
5 Foundation 0x0000000105243ea3 -[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 197
6 Foundation 0x0000000105239dbe -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 96
7 UIKit 0x0000000106474495 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
8 Foundation 0x0000000105247a8e -[NSISEngine withBehaviors:performModifications:] + 155
9 UIKit 0x000000010647429b __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
10 UIKit 0x00000001064740ae -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
11 UIKit 0x0000000106473d21 -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 404
12 UIKit 0x0000000106468caf -[UIView(UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 127
13 UIKit 0x0000000105e66d85 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 207
14 UIKit 0x0000000105e5f9c2 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
15 UIKit 0x0000000105e5f936 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
16 UIKit 0x0000000105e69835 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1550
17 UIKit 0x0000000105e37f43 -[UIWindow addRootViewControllerViewIfPossible] + 452
18 UIKit 0x0000000105e38152 -[UIWindow _setHidden:forced:] + 276
19 UIKit 0x0000000105e4465c -[UIWindow makeKeyAndVisible] + 42
20 UIKit 0x0000000105def191 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
21 UIKit 0x0000000105df1e5c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
22 UIKit 0x0000000105df0d22 -[UIApplication workspaceDidEndTransaction:] + 179
23 FrontBoardServices 0x00000001085a92a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
24 CoreFoundation 0x000000010593cabc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
25 CoreFoundation 0x0000000105932805 __CFRunLoopDoBlocks + 341
26 CoreFoundation 0x00000001059325c5 __CFRunLoopRun + 2389
27 CoreFoundation 0x0000000105931a06 CFRunLoopRunSpecific + 470
28 UIKit 0x0000000105df0799 -[UIApplication _run] + 413
29 UIKit 0x0000000105df3550 UIApplicationMain + 1282
30 Fullscreen Ninja Browser for iPhone 6 0x00000001051723c3 main + 115
31 libdyld.dylib 0x0000000107f7f145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Edit 2: I have discovered that when I "Add missing constraints" to my UIButton, the above error is caused. However, when I clear the constraints, the app runs fine, with the UIWebView showing the site. However, the buttons are out of place, as adding constraints causes the app to crash, annoyingly. Any solutions?

You need to call [super viewDidLoad], before loading your webView,
This should help to resolve your issue,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *url = #"http://www.google.com";
[self createWebpage:url];
self.addressBar.delegate = self;
}

Related

Check value in TextField with NSDictionary Objective C (for Login)

I'am a super a super rookie in IOS. I am doing a login feature. When the login in button is pressed, the APP shall check the text from storage. Then it should change to the second VC if check status return true. I currently have a ViewController to ViewController segue with identifier. I tried the perform segue with identifier but it doesn't work.(Doesn't change scene and shows no alert.)
Here is the login Page.
#import
#interface LoginPage : UIViewController
#property (strong, nonatomic) IBOutlet UITextField *usernameField;
#property (strong, nonatomic) IBOutlet UITextField *passwordField;
- (IBAction)LoginTapped:(id)sender;
- (IBAction)SignupTapped:(id)sender;
#end
the login.m
#import "LoginPage.h"
#import "Home.h"
#implementation LoginPage
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)LoginTapped:(id)sender {
NSMutableDictionary *infodictionary =[[NSMutableDictionary alloc] init];
[infodictionary setObject:#"1" forKey:#"rose"];
[infodictionary setObject:#"2" forKey:#"cathy"];
[infodictionary setObject:#"3" forKey:#"corey"];
if ([_passwordField.text isEqualToString:[infodictionary objectForKey: _usernameField.text]]){
// Home *home = [[Home alloc] init];
[self performSegueWithIdentifier:#"ToHome" sender:self];
}
}
- (IBAction)SignupTapped:(id)sender {
NSString *_NAME = [NSString alloc];
NSString *_PASS = [NSString alloc];
_NAME= _usernameField.text;
_PASS = _passwordField.text;
}
#end
the stimulator gives me terminating with uncaught exception of type NSException
2016-02-07 05:39:49.437 project_feature_login[8249:941926] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7fb5f9c98300> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key passwordField.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102b18f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000102592deb objc_exception_throw + 48
2 CoreFoundation 0x0000000102b18b89 -[NSException raise] + 9
3 Foundation 0x000000010215fa6b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x000000010305004c -[UIViewController setValue:forKey:] + 88
5 UIKit 0x000000010327da71 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000102a59a80 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x000000010327c454 -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000103056c16 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000103057542 -[UIViewController loadView] + 178
10 UIKit 0x00000001030578a0 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000103058013 -[UIViewController view] + 27
12 UIKit 0x0000000102f3151c -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000102f31c05 -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000102f434a5 -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x0000000102ebd396 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x0000000102ec39c3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1750
17 UIKit 0x0000000102ec0ba3 -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x0000000105870784 -[FBSSerialQueue _performNext] + 192
19 FrontBoardServices 0x0000000105870af2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
20 CoreFoundation 0x0000000102a45011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x0000000102a3af3c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x0000000102a3a3f3 __CFRunLoopRun + 867
23 CoreFoundation 0x0000000102a39e08 CFRunLoopRunSpecific + 488
24 UIKit 0x0000000102ec04f5 -[UIApplication _run] + 402
25 UIKit 0x0000000102ec530d UIApplicationMain + 171
26 project_feature_login 0x0000000102094a6f main + 111
27 libdyld.dylib 0x000000010523c92d start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
Seeking for Help!!!!
Try using self.passwordField.text instead of _passwordField.text while verifying your if condition. Also check the IBOutlet connection of passwordField in Interface Builder. Class set for that UIViewController in interface must be LoginPage

crash with insertObject:atIndex: object cannot be nil but no array

I'm fighting with a crash in my app but I can't find where it happens.
I'm working with last version of MZFormSheetController. When I receive a remote push I present a basic MZFormSheetController, it was working nice but from one day to the other it starts crashing with a weird stack trace :
Fatal Exception: NSInvalidArgumentException
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2bfc2fef __exceptionPreprocess + 126
1 libobjc.A.dylib 0x3a274c8b objc_exception_throw + 38
2 CoreFoundation 0x2bedcefb -[__NSArrayM insertObject:atIndex:] + 638
3 UIKit 0x2fb6289f __workaround10030904InvokeWithTarget_block_invoke + 14
4 UIKit 0x2f8b2ab1 +[UIView _performSystemAppearanceModifications:] + 32
5 UIKit 0x2f780639 workaround10030904InvokeWithTarget + 704
6 UIKit 0x2fb5ff3b applyInvocationsToTarget + 1242
7 UIKit 0x2f6bdd8f +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 1262
8 UIKit 0x2f6bd89b +[_UIAppearance _applyInvocationsTo:window:] + 30
9 UIKit 0x2f8bc353 __88-[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]_block_invoke + 54
10 UIKit 0x2f8bc2cb -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] + 262
11 UIKit 0x2f61cf07 -[UIView(Internal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 30
12 UIKit 0x2f633f0f -[UIScrollView _didChangeFromIdiom:onScreen:traverseHierarchy:] + 46
13 UIKit 0x2f8bc1b7 -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] + 138
14 UIKit 0x2f61497d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1316
15 UIKit 0x2f633dfb -[UIScrollView _didMoveFromWindow:toWindow:] + 50
16 UIKit 0x2f6146fb -[UIView(Internal) _didMoveFromWindow:toWindow:] + 674
17 UIKit 0x2f6146fb -[UIView(Internal) _didMoveFromWindow:toWindow:] + 674
18 UIKit 0x2f613fa7 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 114
19 UIKit 0x2f613ec1 -[UIView(Hierarchy) _postMovedFromSuperview:] + 428
20 UIKit 0x2f61e72b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1498
21 UIKit 0x2f61e14b -[UIView(Hierarchy) addSubview:] + 30
22 UIKit 0x2f61db69 -[UIWindow addRootViewControllerViewIfPossible] + 432
23 UIKit 0x2f61b3a1 -[UIWindow _setHidden:forced:] + 272
24 UIKit 0x2f6864a1 -[UIWindow makeKeyAndVisible] + 48
25 Project 0x000f382d -[MZFormSheetController presentAnimated:completionHandler:] (MZFormSheetController.m:509)
26 Project 0x0021b879 __60+[ARDPopupManager showFormsheet:animated:completionHandler:]_block_invoke_2 (ARDPopupManager.m:46)
27 libdispatch.dylib 0x3a7e9ecd _dispatch_barrier_sync_f_slow_invoke + 372
28 libdispatch.dylib 0x3a7df2cf _dispatch_client_callout + 22
29 libdispatch.dylib 0x3a7e2d2f _dispatch_main_queue_callback_4CF + 1330
30 CoreFoundation 0x2bf88609 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
31 CoreFoundation 0x2bf86d09 __CFRunLoopRun + 1512
32 CoreFoundation 0x2bed3201 CFRunLoopRunSpecific + 476
33 CoreFoundation 0x2bed3013 CFRunLoopRunInMode + 106
34 GraphicsServices 0x337b2201 GSEventRunModal + 136
35 UIKit 0x2f677a59 UIApplicationMain + 1440
36 Project 0x0007a88d main (main.m:14)
37 libdyld.dylib 0x3a800aaf start + 2
Of course I understand the crash but the exception breakpoint stops at this line :
[self.formSheetWindow makeKeyAndVisible];
In MZFormSheetController library and the MZFormSheetController is presented from my code like :
[formsheet presentAnimated:animated completionHandler:nil];
I added an All Exception Breakpoint but it does not point to an addObject: or insertObject:atIndex: method. Maybe it is elsewhere but I can't figure it out. I can't find the NSArray causing this crash.
Finally found : in the view controller presented in form sheet controller I added an UITextView and in my AppDelegate I wrote [[UITextView appearance] setKeyboardAppearance:UIKeyboardAppearanceDark]; and it crashes when I present the UITextView. So I had to set keyboard appearance individually on each UITextView instances storyboard or code...
I think it will solve problem.
YourViewController *objVc = [[YourViewController alloc] init]; // or you can use initWithNib
// Your remaining code
MZFormSheetController *formSheet = [[MZFormSheetController alloc]initWithViewController:objVc];
formSheet.transitionStyle = MZFormSheetTransitionStyleSlideFromBottom; //try different style
formSheet.presentedFormSheetSize = CGSizeMake(320, self.view.frame.size.height);
formSheet.willPresentCompletionHandler = ^(UIViewController *presentedFSViewController)
{
presentedFSViewController.view.autoresizingMask = presentedFSViewController.view.autoresizingMask | UIViewAutoresizingFlexibleWidth;
};
formSheet.shouldCenterVertically = YES;
[formSheet presentAnimated:YES completionHandler:^(UIViewController *presentedFSViewController){ }];

Crash on focus UITextField

I am working on an iOS app, but for some reason all of a sudden my login page is not working anymore. All of the UIElements seem to be working fine except for the UITextField I use for the username (Password textField is working fine).
The login screen is very basic, it has a one viewcontroller and the username textfield has one outlet in that viewcontroller.
I don't do anything with the textfield when it focuses.
It happens on iOS8 on the physical iPad 2, and on the iPhone 4s emulator.
What I have tried to do:
Re-install the app
Re-ad the textField
Re-connect the Outlet
Revert my storyboard to a working version
I found some other answers, but none of them seem to have a conclusive answer.
Exception:
2015-03-24 11:13:53.695 App[43084:866627] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7ae5f920
2015-03-24 11:13:53.726 App[43084:866627] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7ae5f920'
*** First throw call stack:
(
0 CoreFoundation 0x00def466 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x006d7a97 objc_exception_throw + 44
2 CoreFoundation 0x00df72c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x00d3fbc7 ___forwarding___ + 1047
4 CoreFoundation 0x00d3f78e _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x00cc531c CFArrayGetValueAtIndex + 188
6 CoreFoundation 0x00d601ed CFStringTokenizerCreate + 749
7 UIKit 0x01c377ce __91-[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:]_block_invoke44 + 264
8 UIFoundation 0x0439e9d3 -[NSTextStorage coordinateReading:] + 51
9 UIKit 0x01c37459 -[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:] + 276
10 UIKit 0x018ba567 -[UITextInputStringTokenizer positionFromPosition:toBoundary:inDirection:] + 93
11 UIKit 0x018bad9d -[TIDocumentState(UITextInputAdditions) _contextBeforePosition:inDocument:] + 81
12 UIKit 0x018baef3 -[TIDocumentState(UITextInputAdditions) initWithDocument:] + 125
13 UIKit 0x018ba95f +[TIDocumentState(UITextInputAdditions) documentStateOfDocument:] + 63
14 UIKit 0x015fad7b -[UIKeyboardImpl syncDocumentStateToInputDelegateWithExecutionContext:] + 298
15 UIKit 0x015fb787 -[UIKeyboardImpl updateForChangedSelectionWithExecutionContext:] + 326
16 UIKit 0x015f57b6 __36-[UIKeyboardImpl setDelegate:force:]_block_invoke + 43
17 UIKit 0x01c384b2 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 404
18 UIKit 0x01c38b6f -[UIKeyboardTaskQueue addTask:] + 144
19 UIKit 0x015f5783 -[UIKeyboardImpl setDelegate:force:] + 2450
20 UIKit 0x015f4dec -[UIKeyboardImpl setDelegate:] + 60
21 UIKit 0x01928fe5 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1096
22 UIKit 0x01570687 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 316
23 UIKit 0x0156f6ec -[UIResponder becomeFirstResponder] + 562
24 UIKit 0x01435ba0 -[UIView(Hierarchy) becomeFirstResponder] + 114
25 UIKit 0x01c04607 -[UITextField becomeFirstResponder] + 51
26 UIKit 0x018051bf -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200
27 UIKit 0x018077e6 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762
28 UIKit 0x017fb057 _UIGestureRecognizerSendActions + 327
29 UIKit 0x017f98d4 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561
30 UIKit 0x017fb91d -[UIGestureRecognizer _delayedUpdateGesture] + 60
31 UIKit 0x017ff29a ___UIGestureRecognizerUpdate_block_invoke661 + 57
32 UIKit 0x017ff15d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
33 UIKit 0x017f3066 _UIGestureRecognizerUpdate + 3720
34 UIKit 0x0140ac5b -[UIWindow _sendGesturesForEvent:] + 1356
35 UIKit 0x0140babf -[UIWindow sendEvent:] + 769
36 UIKit 0x013d0bb1 -[UIApplication sendEvent:] + 242
37 UIKit 0x013e0bf6 _UIApplicationHandleEventFromQueueEvent + 21066
38 UIKit 0x013b4bc7 _UIApplicationHandleEventQueue + 2300
39 CoreFoundation 0x00d1298f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
40 CoreFoundation 0x00d0849d __CFRunLoopDoSources0 + 253
41 CoreFoundation 0x00d079f8 __CFRunLoopRun + 952
42 CoreFoundation 0x00d0737b CFRunLoopRunSpecific + 443
43 CoreFoundation 0x00d071ab CFRunLoopRunInMode + 123
44 GraphicsServices 0x04e182c1 GSEventRunModal + 192
45 GraphicsServices 0x04e180fe GSEventRun + 104
46 UIKit 0x013b89b6 UIApplicationMain + 1526
47 App 0x0005ffbd main + 141
48 libdyld.dylib 0x0296dac9 start + 1
49 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Viewcontroller:
#import "LoginViewController.h"
#implementation LoginViewController
UserManager *usermanager;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)cancelLogin:(id)sender {
[self dismissViewControllerAnimated:true completion:nil];
}
- (IBAction)login:(id)sender {
[loginIndicator startAnimating];
LoginHandler *loginhandler = [[LoginHandler alloc]initWithUsername:usernameField.text
password:passwordField.text
beta:betaSwitch.isOn
view:self];
[loginhandler loginUser];
}
-(void)resetFields{
usernameField.text = #"";
passwordField.text = #"";
[loginIndicator stopAnimating];
}
#end
Viewcontroller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "LoginHandler.h"
#interface LoginViewController : UIViewController{
__weak IBOutlet UITextField *usernameField;
__weak IBOutlet UITextField *passwordField;
__weak IBOutlet UIActivityIndicatorView *loginIndicator;
__weak IBOutlet UISwitch *betaSwitch;
__weak IBOutlet UINavigationBar *navigationBar;
}
-(void)resetFields;
#end
An exception breakpoint gives this line:
2015-03-24 11:43:41.338 App[323:15867] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x15653690
Can anyone else help me?
Thanks
I seem to have found an answer, it had something to do with my constraints for some reason. I cleared the constraints and re-added them and somehow it is working again.

iPhone- Error With Spritekit Game

I'm making a app using Apple's Spritekit framework. My app has multiple view controllers and everything works fine. However, I tried to make a scene that I would load in one of my viewcontrollers, but that did not work. I get no errors at all: it just does not work. Everything works except when I try to load my scene, everything crashes. Also, I was thinking, could my problem be that I have already added a view and put labels and buttons, etc... on that view before I load my scene? To elaborate, could the problem be that I have already added uiimages, etc... to the view using interface builder before I loaded my scene programmatically? Any help would be great. Here is my code for the view controller where I call my scene:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
SKView * skView = (SKView *)self.view;
// Create and configure the scene.
SKScene * scene = [MyScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
And here is my code for the actual scene:
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
/* Setup your scene here */
SKSpriteNode *mainTurrentSprite = [SKSpriteNode spriteNodeWithImageNamed:#"mainTurrent.png"];
mainTurrentSprite.position = CGPointMake(self.view.center.x, 0);
[self addChild:mainTurrentSprite];
}
return self;
}
And here is my crash/error log :
2014-07-22 14:32:34.783 Doodle Defense[6713:60b] -[UIView presentScene:]: unrecognized selector sent to instance 0x9a32630
2014-07-22 14:32:34.786 Doodle Defense[6713:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView presentScene:]: unrecognized selector sent to instance 0x9a32630'
*** First throw call stack:
(
0 CoreFoundation 0x019231e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0168e8e5 objc_exception_throw + 44
2 CoreFoundation 0x019c0243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0191350b ___forwarding___ + 1019
4 CoreFoundation 0x019130ee _CF_forwarding_prep_0 + 14
5 Doodle Defense 0x000020b1 -[GameViewController viewDidLoad] + 337
6 UIKit 0x0034b33d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x0034b5d9 -[UIViewController view] + 35
8 UIKit 0x0035af89 -[UIViewController shouldAutorotate] + 36
9 UIKit 0x0035b2d1 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
10 UIKit 0x005f93d5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
11 UIKit 0x003575d5 -[UIViewController presentViewController:withTransition:completion:] + 6538
12 UIKit 0x00357aef -[UIViewController presentViewController:animated:completion:] + 130
13 UIKit 0x00357b2f -[UIViewController presentModalViewController:animated:] + 56
14 UIKit 0x007a1e00 -[UIStoryboardModalSegue perform] + 271
15 UIKit 0x00790f0c -[UIStoryboardSegueTemplate _perform:] + 174
16 UIKit 0x00790f87 -[UIStoryboardSegueTemplate perform:] + 115
17 libobjc.A.dylib 0x016a0880 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x0022e3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
19 UIKit 0x0022e345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
20 UIKit 0x0032fbd1 -[UIControl sendAction:to:forEvent:] + 66
21 UIKit 0x0032ffc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
22 UIKit 0x0032f243 -[UIControl touchesEnded:withEvent:] + 641
23 UIKit 0x0026dddd -[UIWindow _sendTouchesForEvent:] + 852
24 UIKit 0x0026e9d1 -[UIWindow sendEvent:] + 1117
25 UIKit 0x002405f2 -[UIApplication sendEvent:] + 242
26 UIKit 0x0022a353 _UIApplicationHandleEventQueue + 11455
27 CoreFoundation 0x018ac77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
28 CoreFoundation 0x018ac10b __CFRunLoopDoSources0 + 235
29 CoreFoundation 0x018c91ae __CFRunLoopRun + 910
30 CoreFoundation 0x018c89d3 CFRunLoopRunSpecific + 467
31 CoreFoundation 0x018c87eb CFRunLoopRunInMode + 123
32 GraphicsServices 0x039035ee GSEventRunModal + 192
33 GraphicsServices 0x0390342b GSEventRun + 104
34 UIKit 0x0022cf9b UIApplicationMain + 1225
35 Doodle Defense 0x00002add main + 141
36 libdyld.dylib 0x01f56701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

UIWebView throwing NSUnknownKeyException iPad

I have a tab bar application. Everything works normally, and I can switch between tabs fine and everything, except when I switch to my second tab ProductViewClass the view doesn't update and it spits out the console output below. I have nothing in this view except for a UIWebView and a UILabel. When I delete the UIWebView it runs successfully, and when I add another it still works. It only stops working when I connect the IBOutlet from my File's Owner to the UIWebView. Besides synthesizing and releasing productWebView the only non-template code in ProductWebView.m is this:
NSString *urlString = #"http://www.google.com/";
NSURL *theURL = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:theURL];
[productWebView loadRequest:urlRequest];
NSLog(#"Google loaded");
The entirety of ProductWebView.h is as follows:
#import <UIKit/UIKit.h>
#interface ProductViewClass : UIViewController {
IBOutlet UIWebView *productWebView;
}
#property(nonatomic, retain) UIWebView *productWebView;
#end
Here's the console output:
This GDB was configured as "x86_64-apple-darwin".Attaching to process 52523.
2011-01-30 19:18:28.907 FairCom[52523:40b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4d06eb0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key productWebView.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00da8be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00efd5c2 objc_exception_throw + 47
2 CoreFoundation 0x00da8b21 -[NSException raise] + 17
3 Foundation 0x000296cf _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0002963d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004a88d6 -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d1f2cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004a72ed -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004a9081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x00361a94 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x0035f709 -[UIViewController loadView] + 120
11 UIKit 0x0035f5e3 -[UIViewController view] + 56
12 UIKit 0x00372230 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
13 UIKit 0x00370d86 -[UITabBarController transitionFromViewController:toViewController:] + 64
14 UIKit 0x00372b7e -[UITabBarController _setSelectedViewController:] + 263
15 UIKit 0x003729ed -[UITabBarController _tabBarItemClicked:] + 352
16 UIKit 0x002b1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
17 UIKit 0x004af1f2 -[UITabBar _sendAction:withEvent:] + 422
18 UIKit 0x002b1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
19 UIKit 0x003401b5 -[UIControl sendAction:to:forEvent:] + 67
20 UIKit 0x00342647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
21 UIKit 0x0034016c -[UIControl sendActionsForControlEvents:] + 49
22 UIKit 0x002b1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
23 UIKit 0x003401b5 -[UIControl sendAction:to:forEvent:] + 67
24 UIKit 0x00342647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
25 UIKit 0x003411f4 -[UIControl touchesEnded:withEvent:] + 458
26 UIKit 0x002d60d1 -[UIWindow _sendTouchesForEvent:] + 567
27 UIKit 0x002b737a -[UIApplication sendEvent:] + 447
28 UIKit 0x002bc732 _UIApplicationHandleEvent + 7576
29 GraphicsServices 0x016dea36 PurpleEventCallback + 1550
30 CoreFoundation 0x00d8a064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
31 CoreFoundation 0x00cea6f7 __CFRunLoopDoSource1 + 215
32 CoreFoundation 0x00ce7983 __CFRunLoopRun + 979
33 CoreFoundation 0x00ce7240 CFRunLoopRunSpecific + 208
34 CoreFoundation 0x00ce7161 CFRunLoopRunInMode + 97
35 GraphicsServices 0x016dd268 GSEventRunModal + 217
36 GraphicsServices 0x016dd32d GSEventRun + 115
37 UIKit 0x002c042e UIApplicationMain + 1160
38 FairCom 0x00001be0 main + 102
39 FairCom 0x00001b71 start + 53
40 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
(gdb)
Thanks for your help!
You're loading a nib. In that nib, you have an outlet named productWebView that's hooked up, presumably to a web view. The exception you're seeing is telling you that the outlet productWebView doesn't actually exist. Here's where it gets weird. The error says the object <UIViewController 0x4d06eb0> is the one that has this missing outlet. The weird bit is where it says UIViewController instead of the name of an actual view controller subclass. It sounds like you have a nib where the File's Owner is set up as one of your view controller subclasses, but at runtime you're actually just using an instance of UIViewController directly. You should verify that all the view controllers representing tabs in your tab bar controller are actual correct subclasses of UIViewController instead of just an instance of UIViewController itself.

Resources