Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Draw This
($0.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-23-2009, 07:52 AM   #256 (permalink)
bigbad
Registered Member
 
Join Date: Jul 2009
Posts: 29
bigbad is on a distinguished road
Default

ok so I fixed it... (or more to the point used the app documentation code to do so) - for anyone else wanting to do these same code is below

Everything works except that now I am getting

Code:
warning:'UIViewController' may not respond to '-viewDidUnload'
in the -(void)viewDidUnload

I have read around and either the fixes posted don't apply or (and this is probably more likely) I just don't get it...

the app seems to work though...


h.
Code:
#import <UIKit/UIKit.h>

@interface Case33ans : UIViewController <UITextFieldDelegate, UIWebViewDelegate>
{
	UIWebView *myWebView;
}

@property (nonatomic, retain) UIWebView	*myWebView;

@end

m.
Code:
#import "Case33ans.h"


@implementation Case33ans
@synthesize myWebView;

- (void)dealloc
{
	myWebView.delegate = nil;
	[myWebView release];
	
	[super dealloc];
}

- (void)viewDidLoad
{
	[super viewDidLoad];
	
	NSString *path;
	NSBundle *thisBundle = [NSBundle mainBundle];
	NSURL *instructionsURL;
	
	self.title = NSLocalizedString(@" ", @"");
	
	CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
	self.myWebView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
	self.myWebView.backgroundColor = [UIColor whiteColor];
	self.myWebView.scalesPageToFit = YES;
	self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	self.myWebView.delegate = self;
	[self.view addSubview: self.myWebView];
	
	path = [thisBundle pathForResource:@"Case33ans" ofType:@"html"];
	
	instructionsURL = [[NSURL alloc] initFileURLWithPath:path];
    [myWebView loadRequest:[NSURLRequest requestWithURL:instructionsURL]];
	
	

}


- (void)viewDidUnload
{
	[super viewDidUnload];
	
	// release and set to nil
	self.myWebView = nil;
}


#pragma mark -
#pragma mark UIViewController delegate methods

- (void)viewWillAppear:(BOOL)animated
{
	self.myWebView.delegate = self;	// setup the delegate as the web view is shown
}

- (void)viewWillDisappear:(BOOL)animated
{
    [self.myWebView stopLoading];	// in case the web view is still loading its content
	self.myWebView.delegate = nil;	// disconnect the delegate as the webview is hidden
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
	// we support rotation in this view controller
	return YES;
}

// this helps dismiss the keyboard when the "Done" button is clicked
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	[textField resignFirstResponder];
	[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[textField text]]]];
	
	return YES;
}


#pragma mark -
#pragma mark UIWebViewDelegate

- (void)webViewDidStartLoad:(UIWebView *)webView
{
	// starting the load, show the activity indicator in the status bar
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
	// finished loading, hide the activity indicator in the status bar
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
	// load error, hide the activity indicator in the status bar
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
	
	// report the error inside the webview
	NSString* errorString = [NSString stringWithFormat:
							 @"<html><center><font size=+5 color='red'>An error occurred:<br>%@</font></center></html>",
							 error.localizedDescription];
	[self.myWebView loadHTMLString:errorString baseURL:nil];
}

@end
thanks, - frank.
bigbad is offline   Reply With Quote
 

» Advertisements
» Online Users: 586
13 members and 573 guests
chiataytuday, christina2c, Domele, Droverson, Dump3, Fstuff, iamwayne5, jerrasen, kanishadg35, linkmx, Techgirl-52, ThistleCoast, timchen
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 174,552
Threads: 93,729
Posts: 401,268
Top Poster: BrianSlick (7,954)
Welcome to our newest member, christina2c
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:12 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.