p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning iOS 4 Application Development (http://p2p.wrox.com/forumdisplay.php?f=599)
-   -   Chapter 3 Using the Alert View (http://p2p.wrox.com/showthread.php?t=82006)

Santi December 22nd, 2010 04:31 PM

Chapter 3 Using the Alert View
 
Please if someone can help me
I just start to learn IOS and I copy simple code and run the IOS Simulator and it show a blank screen, doesn't show the "Hello", "This is an alert view"

- (void)viewDidUnload {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello"
message:@"This is an alert view"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];

[alert show];
[alert release];
[super viewDidLoad];

}

Bugslayer December 25th, 2010 11:06 PM

Not viewDidUnload, but viewDidLoad
 
You should implement the code at viewDidLoad method, not viewDidUnload. :)

Santi December 26th, 2010 09:37 PM

Thank you!!!
 
thank you for your help. I really appreciate

milpitian February 6th, 2011 12:40 AM

Also getting blank.
 
I inserted the code on viewDidLoad, but like the person above still showing a blank screen.

------------


//
// UsingViewsViewController.m
// UsingViews
//
// Created by Dean on 2/5/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "UsingViewsViewController.h"

@implementation UsingViewsViewController




/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello"
message:@"This is an alert view"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];

[alert show];
[alert release];
[super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIIn terfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}

@end

milpitian February 6th, 2011 12:40 PM

i dont know if its related to my issue here, but im a noob at programming so bare with me. i noticed that when i typed the code under - (void) viewDidLoad
it is not automating the code or giving it color.it remained under green color text.is that mean that i have to convert it somehow?or the color change has nothing to do with how the code executes as long as you input it correctly?

Gryphon February 6th, 2011 05:27 PM

Quote:

Originally Posted by milpitian (Post 268418)
I inserted the code on viewDidLoad, but like the person above still showing a blank screen.

Code:

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
 UIAlertView *alert = [[UIAlertView alloc]
 initWithTitle:@"Hello"
 message:@"This is an alert view"
 delegate:self
 cancelButtonTitle:@"OK"
 otherButtonTitles:nil];
 
 [alert show];
 [alert release];
 [super viewDidLoad];
}
*/


You need to remove the "/*" and "*/" surrounding viewDidLoad (highlighted in red). They mark the beginning & end of a comment block & cause the compiler to ignore everything in between. That also explains why the text was all green.


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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.