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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-07-2011, 12:43 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
glucklich_us is on a distinguished road
Default How to correctly dismiss a UIWebView?

Hi

I am creating programmatically a UIWebView as a result of a tap event on a UiTextView. The tap basically fires the UiWebView to display the contents
of the textView from the web in more detail. I add a button to the UiWebView with the intent to dismiss the UiWebView when one clicks the button. My question is how do I make the UiWebView disappear when the button is clicked. Any help is appreciated.

thanks
nick
glucklich_us is offline   Reply With Quote
Old 03-07-2011, 12:51 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

How do you make it appear in the first place?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-07-2011, 01:18 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
glucklich_us is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
How do you make it appear in the first place?
Hi Brian

Here is a snippet:

-(IBAction) handleTapGesture: (UIGestureRecognizer *) sender
{
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 600, 500)];//init and create the UIWebView
aWebView.autoresizesSubviews = YES;
aWebView.autoresizingMask=(UIViewAutoresizingFlexi bleHeight | UIViewAutoresizingFlexibleWidth);
//set the web view delegates for the web view to be itself
//[aWebView setDelegate:self];
//Set the URL to go to for your UIWebView
NSString *urlAddress = @"http://www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//load the URL into the web view.
[aWebView loadRequest:requestObj];
//add the web view to the content view
aWebView.tag = 100;
[self.view addSubview:aWebView];

UIButton *bb = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[bb addTarget:self
action:@selector(aMethod
forControlEvents:UIControlEventTouchDown];
[bb setTitle:@"Show View" forState:UIControlStateNormal];
bb.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:bb];
}
glucklich_us is offline   Reply With Quote
Old 03-07-2011, 01:26 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

The opposite of addSubview: is removeFromSuperview.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-07-2011, 01:42 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
glucklich_us is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
The opposite of addSubview: is removeFromSuperview.
Hi Brian

I am trying to dismiss it:

-(void) aMethod
{

UIWebView *w = (UIWebView*) [self.view viewWithTag:100];
[self.view removeFromSuperview:w];

}

but I am getting that UiView may not recognize removeFromSuperview and the application crashes. Any ideas?

thanks again
nick
glucklich_us is offline   Reply With Quote
Old 03-07-2011, 01:50 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

It is removeFromSuperview, NOT removeFromSuperview:

You're doing it against the wrong view.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-07-2011, 02:01 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
glucklich_us is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
It is removeFromSuperview, NOT removeFromSuperview:

You're doing it against the wrong view.
thanks Brian, still getting an error though:

-(void) aMethod
{

UIWebView *w = (UIWebView*) [self.view viewWithTag:100];
[w removeFromSuperview];

}

do I obtain a wrong reference to w somehow?

thanks
nick
glucklich_us is offline   Reply With Quote
Old 03-07-2011, 02:03 PM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

What error?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-07-2011, 02:11 PM   #9 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
glucklich_us is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
What error?
here it is from console:

2011-03-07 15:11:03.843 SplitTabBar[25914:207] -[DetailViewController aMethod:]: unrecognized selector sent to instance 0x4e0ea70
2011-03-07 15:11:03.844 SplitTabBar[25914:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController aMethod:]: unrecognized selector sent to instance 0x4e0ea70'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dbbbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f105c2 objc_exception_throw + 47
2 CoreFoundation 0x00dbd6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d2d366 ___forwarding___ + 966
4 CoreFoundation 0x00d2cf22 _CF_forwarding_prep_0 + 50
5 UIKit 0x002c4a6e -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x003531b5 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00355647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x00354438 -[UIControl touchesBegan:withEvent:] + 277
9 UIKit 0x002e9025 -[UIWindow _sendTouchesForEvent:] + 395
10 UIKit 0x002ca37a -[UIApplication sendEvent:] + 447
11 UIKit 0x002cf732 _UIApplicationHandleEvent + 7576
12 GraphicsServices 0x016f1a36 PurpleEventCallback + 1550
13 CoreFoundation 0x00d9d064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FU NCTION__ + 52
14 CoreFoundation 0x00cfd6f7 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x00cfa983 __CFRunLoopRun + 979
16 CoreFoundation 0x00cfa240 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x00cfa161 CFRunLoopRunInMode + 97
18 GraphicsServices 0x016f0268 GSEventRunModal + 217
19 GraphicsServices 0x016f032d GSEventRun + 115
20 UIKit 0x002d342e UIApplicationMain + 1160
21 SplitTabBar 0x00002248 main + 102
22 SplitTabBar 0x000021d9 start + 53
)
terminate called after throwing an instance of 'NSException'
glucklich_us is offline   Reply With Quote
Old 03-07-2011, 02:24 PM   #10 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Ok...

Code:
[DetailViewController aMethod:]: unrecognized selector sent to instance 0x4e0ea70
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-07-2011, 02:28 PM   #11 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
glucklich_us is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Ok...

Code:
[DetailViewController aMethod:]: unrecognized selector sent to instance 0x4e0ea70
Hi Brian

if you have any ideas please let me know, I appreciate it

thanks
nick
glucklich_us is offline   Reply With Quote
Old 03-07-2011, 02:29 PM   #12 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You are calling the wrong method. Read what the error is telling you.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
cocoa touch, uiwebview, xcode

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: 365
17 members and 348 guests
Absentia, akphyo, apatsufas, BinHex, dre, fredidf, Gaz, gmarro, host number one, jeroenkeij, Kirkout, MarkC, mottdog, Music Man, PavelMik, whitey99, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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