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 07-07-2010, 04:38 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 3
rsebastian is on a distinguished road
Default Setting default image after statement

Hey guys,

I've got a question about ImageView. I got a setup for loading all my info via the UIWebView function and it works just fine. I've also build a check to see if there is any connection or not. This also works like it supposed to do. Do only thing i want to do is to show an image if there's no connection.

Here's my code in Viewcontroller.m

Code:
-(void)viewDidLoad{
	
	
	NSString *connectionstring = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"MYWEBSITE"]];
	
	//If there is no connection:
	if([connectionstring length] == 0){
		UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Error" message:@You have to be connected to the internet to use this app" delegate:self cancelButtonTitle:@"Oke" otherButtonTitles:nil];
		[alertview show];
		[alertview release];
		
	//If there is a connection:	
	}else{
		[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"MYWEBSITE"]]];
	}
	
	//Release your string:
	[connectionstring release];	
}
The image i want to add is called "Default.png".

Thanks if you could help!
rsebastian is offline   Reply With Quote
Old 07-07-2010, 11:44 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Location: Netherlands
Posts: 28
TwanB is on a distinguished road
Default

Ik laad eerst een lokale html-file op deze manier:

Code:
	[mainView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index2.html" ofType:@""]isDirectory:NO]]];
TwanB is offline   Reply With Quote
Old 07-08-2010, 05:08 AM   #3 (permalink)
el guaje
 
kevinyide's Avatar
 
Join Date: Jun 2010
Posts: 243
kevinyide is on a distinguished road
Send a message via Yahoo to kevinyide
Default

Is the image view in IB or created programmatically?

To add an ImageView programmatically,

Code:
CGRect imageViewFrame = CGRectMake( 150.0f, 150.0f, 20.0f, 20.0f);
UIImageView *imageView = [[UIImageView alloc]initWithFrame:imageViewFrame];
[imageView setImage:[UIImage imageNamed:@"Default.png"]];
[self.view addSubview:imageView];
You could declare your imageView in your .h so that you can access it from anywhere in your .m. Also, you could change the CGRectMake(x,y,width,height) values to your requirement.

To add an ImageView using IB.
1. Drop an imageview from the library and place it where you want it to be seen in the view.
2. Create and IBOutlet & connect it to the imageview in IB
3. in your .m, set your image like this
Code:
imgViewOutlet.image = [UIImage imageNamed:@"Default.png"];
Hope this helps.
kevinyide is offline   Reply With Quote
Old 07-08-2010, 08:34 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2010
Location: Milano
Posts: 99
zero_ is on a distinguished road
Default

or you can add in IB your imageview with the image and set to hidden, declare in .h the imageview and into your if you can set imagevie.hidden = NO/YES when you need to visualiza/remove the image.
zero_ is offline   Reply With Quote
Reply

Bookmarks

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: 338
9 members and 329 guests
bignoggins, Chickenrig, firecall, givensur, iNet, michaelhansen, Objective Zero, PlutoPrime, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,893
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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