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

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

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-11-2010, 05:08 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 10
srikanth is on a distinguished road
Default how can we open a web link in coco2d ?

Hi, I need to open a webpage when I touched a label in the coco2d layer. It should be opened by using safari. I am stuck at adding the view to the coco2d layer ? How can I resolve this ?
Thank you.
srikanth is offline   Reply With Quote
Old 05-11-2010, 09:46 AM   #2 (permalink)
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
Johanovski is on a distinguished road
Default

Quote:
Originally Posted by srikanth View Post
Hi, I need to open a webpage when I touched a label in the coco2d layer. It should be opened by using safari. I am stuck at adding the view to the coco2d layer ? How can I resolve this ?
Thank you.
Hi there!

I think it's not possible to attach a UIWebView in Cocos2D (in fact I think Cocos2D and IB objects aren't good friends)...
Do you want to web page to be opened inside your app, or it is OK for you to close your app and open the safari app when the layer is touched? If the last one is what you're seeking this may help you:
Code:
// Put this in the action called when you touch the layer:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.google.com"]];
This will close your app an open the Safari app by the webpage.

Hope it helped!
Johanovski is offline   Reply With Quote
Old 05-11-2010, 06:56 PM   #3 (permalink)
iPhone SDK learner
 
Join Date: Feb 2010
Location: Illinois, USA
Posts: 421
Batman is on a distinguished road
Default

Code:
[[[CCDirector sharedDirector] openglview] window] addSubview:yourwebview];
or something along the line.
Batman is offline   Reply With Quote
Old 05-13-2010, 11:50 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 10
srikanth is on a distinguished road
Default

Quote:
Originally Posted by Johanovski View Post
Hi there!

I think it's not possible to attach a UIWebView in Cocos2D (in fact I think Cocos2D and IB objects aren't good friends)...
Do you want to web page to be opened inside your app, or it is OK for you to close your app and open the safari app when the layer is touched? If the last one is what you're seeking this may help you:
Code:
// Put this in the action called when you touch the layer:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.google.com"]];
This will close your app an open the Safari app by the webpage.

Hope it helped!
Hi Johanovski,
It helped me. It is working perfect. Thank You.
srikanth is offline   Reply With Quote
Old 05-13-2010, 11:53 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 10
srikanth is on a distinguished road
Default

Quote:
Originally Posted by Batman View Post
Code:
[[[CCDirector sharedDirector] openglview] window] addSubview:yourwebview];
or something along the line.
Hi, Batman

I think adding a webView is difficult than url thing. I used url thing for now. It is working good. I would try adding webView and I post weather I succeed or not.

Thank You for the solution.
srikanth is offline   Reply With Quote
Reply

Bookmarks

Tags
cocoa-touch, cocos2d, uitextview

Thread Tools
Display Modes

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



» Advertisements
» Online Users: 406
10 members and 396 guests
7twenty7, ChrisYates, djohnson, Duncan C, gmarro, Kirkout, Retouchable, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:04 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0