New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

webView


Post Reply New Thread Subscribe

 
Thread Tools
gal

 
Member Since: Nov 04, 2012
Posts: 3
gal is on a distinguished road

gal is offline
Hello,
i want to do that when i launch the program its automatically will open google web site in webView (for os x system).
i dont have prior knowledge of programming language and Xcode.
thanks !!
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,352
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
According to the developer documentation, you want the setMainFrameURL method (see here for more info). I don't have Xcode installed so I can't verify this but you might also be able to set this property when you design the interface.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
gal

 
Member Since: Nov 04, 2012
Posts: 3
gal is on a distinguished road

gal is offline
i created a new class with the name "webView" and i put this code:
Quote:
[[webView MainFrame] loadRequestNSURLRequest requestWithURL: [NSURL URLWithString:@"http://google.com"]]];
in AppDelegate.m in applicationDidFinishLaunching function and its says me "use of undeclared identifier 'webView' " but i set the identifier to 'webView'
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 170
Mark FX has a spectacular aura about

Mark FX is offline
You have to add the WebKit Framework to your project.

Secondly make sure you have an initialized instance of a WebView class.

only after that will your code work.

Also there is another WebView instance method, that only requires a URL String.
Code:
- (void)setMainFrameURL:(NSString *)URLString
Regards Mark
QUOTE Thanks
gal

 
Member Since: Nov 04, 2012
Posts: 3
gal is on a distinguished road

gal is offline
thanks for everyone but it doesn't work..
here's my project (there isn't errors but it doesn't work):





QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 170
Mark FX has a spectacular aura about

Mark FX is offline
Your code should be more something like this.

AppDelegate.h
Code:
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>
{
    IBOutlet WebView *webView;
    IBOutlet NSTextField *navbar;
    
    NSString *urlText;
}

@property (nonatomic, readonly, assign) IBOutlet NSWindow *window;

@property (nonatomic, readonly, retain)WebView *webView;
@property (nonatomic, readonly, retain)NSTextField *navbar;

@property (nonatomic, readwrite, copy)NSString *urlText;

- (IBAction)go:(id)sender;

@end
AppDelegate.m
Code:
#import "AppDelegate.h"

@implementation AppDelegate

@synthesize webView, navbar, urlText;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    
    urlText = [NSString stringWithFormat:@"http://www.Google.com"];
    [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
}

- (IBAction)go:(id)sender
{
    urlText = [navbar stringValue];
    [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
}

@end
There is a lot of things you have to do, to get this into a fully fledged browser, this is only
the very basic of code, with no error checking, and it assumes a lot, like the address typed
into your navbar is a correct address.

Also you need to implement the frame load delegate protocol, if you want to monitor the
web page loading progress, or check for network errors.

Try reading the Apple Developer documentation, relating to the WebKit Framework.

https://developer.apple.com/library/.../uid/10000164i

Regards Mark
QUOTE Thanks

Post Reply New Thread Subscribe


« xcode C++ library help | Xcode 4.5.2 »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
WebView in NSWindow and keyboard events albanvn OS X - Development and Darwin 0 05-06-2010 11:17 AM
Bug in WebView cocoa? Toreddo OS X - Development and Darwin 0 04-28-2010 05:53 AM

All times are GMT -4. The time now is 09:38 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?