Wrox Programmer Forums
|
BOOK: Beginning iOS 4 Application Development
This is the forum to discuss the Wrox book Beginning iOS 4 Application Development by Wei-Meng Lee; ISBN: 978-0-470-91802-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2011, 11:23 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Ch. 3 - Using the Web View - UsingViews2

New to mobile apps but not new to programming...ran into first significant problem as stated in the title.

Loading the project into the simulator
- app begins to appear (in other words the screen looks as I expect)
- no web page appears
- app disappears (without action by me) and the empty simulator 'desktop' appears with Safari and Photos icons, as well as the icon for UsingViews2

UsingViews2ViewController.h
---------------------------------
Code:
#import <UIKit/UIKit.h>
@interface UsingViews2ViewController : UIViewController {
	IBOutlet UIWebView *webView;
}
@property (nonatomic, retain) UIWebView *webView;
@end
UsingViews2ViewController.m
---------------------------------
Code:
#import "UsingViews2ViewController.h"
@implementation UsingViews2ViewController
@synthesize webView;
- (void) viewDidLoad {
	NSURL *url = [NSURL URLWithString:@"http://www.apple.com"];
	NSURLRequest *req = [NSURLRequest requestWithURL:url];
	[webView loadRequest:req];
	[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}
- (void)dealloc {
	[webView release];
    [super dealloc];
}
@end
- UIWebView placed in the View
- webView connected to the UIWebView via ctrl-click and drag 'File's Owner' to View-UIWebView and selecting webView

Any ideas?

Thx
 
Old July 14th, 2011, 11:59 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The error is not in your code, so it must be in the Interface. When the app crashes are you getting any messages in the console?

I would recheck the .xib . If you can't locate the problem, send the project to
[email protected]

and I should be able to spot it.

Bob
 
Old July 15th, 2011, 10:03 AM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you. Console output below - this makes sense because when I ctrl-drag from the File's Owner to the View, I get a popup with both 'Webview' (the name of the Web View in the interface) and 'view' (and I don't know what this is). I've been connected to 'Webview'. So the 'view' is not connected but I don't know what the 'view' is or where it came from.
----------------

2011-07-15 07:57:36.845 UsingViews2[16438:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "UsingViews2ViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc75a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f1b313 objc_exception_throw + 44
2 CoreFoundation 0x00d7fef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7fe6a +[NSException raise:format:] + 58
4 UIKit 0x00369709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x00367134 -[UIViewController loadView] + 120
6 UIKit 0x0036700e -[UIViewController view] + 56
7 UIKit 0x002dad42 -[UIWindow addRootViewControllerViewIfPossible] + 51
8 UIKit 0x002da22d -[UIWindow _setHidden:forced:] + 303
9 UIKit 0x002da01d -[UIWindow _orderFrontWithoutMakingKey] + 50
10 UIKit 0x002d8cd1 -[UIWindow makeKeyAndVisible] + 39
11 UsingViews2 0x000022d2 -[UsingViews2AppDelegate application:didFinishLaunchingWithOptions:] + 135
12 UIKit 0x002b7c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspend ed:] + 1163
13 UIKit 0x002b9d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarSty le:statusBarHidden:] + 439
14 UIKit 0x002c4617 -[UIApplication handleEvent:withNewEvent:] + 1533
15 UIKit 0x002bcabf -[UIApplication sendEvent:] + 71
16 UIKit 0x002c1f2e _UIApplicationHandleEvent + 7576
17 GraphicsServices 0x0171f992 PurpleEventCallback + 1550
18 CoreFoundation 0x00da8944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FU NCTION__ + 52
19 CoreFoundation 0x00d08cf7 __CFRunLoopDoSource1 + 215
20 CoreFoundation 0x00d05f83 __CFRunLoopRun + 979
21 CoreFoundation 0x00d05840 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x00d05761 CFRunLoopRunInMode + 97
23 UIKit 0x002b97d2 -[UIApplication _run] + 623
24 UIKit 0x002c5c93 UIApplicationMain + 1160
25 UsingViews2 0x00002228 main + 102
26 UsingViews2 0x000021b9 start + 53
)
terminate called after throwing an instance of 'NSException'
 
Old July 15th, 2011, 10:15 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

There should be 2 outlets in the File's Owner in UsingViews2ViewController.xib, a 'view' outlet and a 'webView' outlet. The webView is embedded in a UIView. Make sure the view outlet is connected to the UIView and the webView is connected to the UIWebView. The first connection should have already been made when the template was loaded. (it is not something you should have had to connect) Maybe somehow it was disconnected.

Bob
The Following User Says Thank You to thepianoguy For This Useful Post:
codan (July 15th, 2011)
 
Old July 15th, 2011, 11:09 AM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

That did it. Somehow the view outlet got disconnected from the UIView. I fixed it and this works perfectly now.

I'm not understanding outlets yet but making progress.

Thank you very much for pointing me in the right direction.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 4 -- Split-View Based App, pg. 121 sirab33 BOOK: Beginning iOS 4 Application Development 2 May 25th, 2011 06:37 PM
Ch.7 Switching to another view p.176-177 solg BOOK: Beginning iPhone SDK Programming with Objective-C 2 May 11th, 2011 02:28 PM
Ch. 4 Enable View State with FileUpload control gerry789 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 December 15th, 2008 03:22 AM
CH 10 Updatepanel - Design view RobertVL ASP.NET 3.5 Basics 2 July 6th, 2008 06:13 AM
Ch 3 p72 "View XSL Output" Justin Abbott XSLT 3 July 15th, 2003 02:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.