Friday, August 27, 2010

UIWebView Tutorial

In this tutorial I will explain how to create a UIWebView. The most common use of a UIWebView is to make your very own Safari Browser. So lets begin. The first thing you do is create a new project. Then in the .h file

Apple's Documentation on UIWebViews:

http://developer.apple.com/iphone/library/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html






This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.

If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.

UIAlertView Tutorial AKA Popup Message in XCODE.

This is how you create an UIAlertView AKA Popup message in XCODE.

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"Message Title"
message:@"You Message ."
delegate:self
cancelButtonTitle:@"Continue"
otherButtonTitles:nil];
[alert show];
[alert release];

This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.

How to add a delay of Timer between the execution of two lines of code in XCODE...

In this tutorial I am going to demenstrate how to add a Timer or delay between the execution of two lines of code. For example lets say you have one button and one UILABEL in a your xcode project. When the user clicks on the button it is to do the following:

1.)  send the variable dice to the UILABEL
2.) Two seconds later it will clear the text on the label.

This is how I have gotten this accomplished.

I have an IBACTION called randomNumber that I have linked to the button in my project.


-(IBAction)randomNumber {
int dice = 1 + arc4random() % (20);
label.text = [NSString stringWithFormat:@"%d", dice];
// perform selector after delay
[self performSelector:@selector(ClearLabel) withObject:nil afterDelay:2];

}

- (void)ClearLabel 

{
label.text = @"";
}

This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00. 
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users

How to call a method AKA IBACTION in an XCODE project.

To call a Method or IBACTION in an XCODE project you have to use the following command.




[self methodname];




for example lets say you have the following methods AKA IBACTIONS in your .h file of you xcode project.




-(IBAction)method1;
-(IBAction)method2;

-(IBAction)method3;

-(IBAction)method4;





And you have all of them defined as following in your .M File of your XCODE project.


-(IBAction)method1

{

//do something

}







-(IBAction)method2


{


//do something


}









-(IBAction)method3


{


//do something


}









-(IBAction)method4


{


//do something


}
















Now for example if you want to call method2 from method1 you will do the following:







-(IBAction)method1


{


[self method2];






}






This is a fundamental concept in XCODE to understand.




This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.