Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-30-2008, 06:18 PM
Junior Member
 
Join Date: Jun 2008
Posts: 8
Default UIWebView

Ok here is how to make a simple webview

In your .h file

Code:
@interface YourViewController : UIViewController<UIWebViewDelegate> {
	UIWebView *dailyWebView;

}
@property(nonatomic, retain) UIWebView *dailyWebView;
@end
And in the .m
Code:
@synthesize dailyWebView

- (void)awakeFromNib{
	
	UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
	contentView.backgroundColor = [UIColor lightGrayColor];
	self.view = contentView;
	[contentView release];
	dailyWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
	dailyWebView.delegate=self;
	dailyWebView.scalesPageToFit=YES;
	[dailyWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
	[self.view addSubview:dailyWebView];}
And be sure to release your web view at dealloc with
Code:
	[dailyWebView release];

Last edited by macdaddy2201; 06-30-2008 at 10:26 PM.
Reply With Quote
  #2 (permalink)  
Old 09-06-2008, 09:05 PM
ToM ToM is offline
Junior Member
 
Join Date: Aug 2008
Posts: 8
Default

Thanks for this, just realised I missed a line out of my code!

Also, you missed a ';' after the synthesize bit.
Reply With Quote
  #3 (permalink)  
Old 09-08-2008, 10:18 AM
Junior Member
 
Join Date: Sep 2008
Posts: 6
Default

Is there an advantage in doing this totally programmaticly in stead of using Interface Builder doing most of the code for you?
Reply With Quote
  #4 (permalink)  
Old 09-09-2008, 03:26 AM
Administrator
 
Join Date: Jun 2008
Location: Arizona
Posts: 409
Send a message via AIM to mxweas Send a message via Yahoo to mxweas Send a message via Skype™ to mxweas
Default

Yes, you can reference specific items and it is faster to load. Whenever you make something in IB, the xib is parsed on the spot, where as UI stuff that has been programmed runs without having to parse a xib file. So performance is better when not using IB

Max
Reply With Quote
  #5 (permalink)  
Old 09-09-2008, 08:41 AM
Junior Member
 
Join Date: Sep 2008
Posts: 6
Default

Thanks for your answer mxweas!

I have another litte question about UIWebView. What I want to do is to send variables in the url, like so:

Code:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com/index.php?var1=%.f3&var2=%.3f",var1,var2]]];
But I can't seem to get this working. Any ideas about it?

edit: I just found the solution
Code:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.example.comindex.php?var1=%.6f&var2=%.6f",variable1,variable2]]]];
just if anyone should want to know

Last edited by psychonikeo; 09-09-2008 at 03:38 PM.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:08 PM.

idevkit.com.sharedcopy.com