UIWebView
-(void)viewDidLoad
{
CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor whiteColor]];
[webView setDelegate:self];
NSString *urlAddress = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:urlAddress];
*requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[self addSubview:webView];
[webView release];
}
//Web View delegate methods
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
//started loading
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//Finished loading
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
//Error in loading
}
UItextField
-(void)viewDidLoad
{
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 30, 150, 40)];
NSLog(@"LOAD");
[textField setBorderStyle:UITextBorderStyleRoundedRect];
[textField setFont:[UIFont systemFontOfSize:28]];
[textField setTextColor:[UIColor redColor]];
[textField setBackgroundColor:[UIColor yellowColor]];
[textField setAdjustsFontSizeToFitWidth:YES];
[textField setClearButtonMode:UITextFieldViewModeWhileEditing];
[textField setReturnKeyType:UIReturnKeyDone];
[textField setKeyboardAppearance:UIKeyboardAppearanceAlert];
//[textField setDelegate:self];
//[textField setText:@"SAMPLE"];
[self.view addSubview:textField];
//[textField becomeFirstResponder];
[textField release];
}
Text field Delegate Methods
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
NSLog(@"BEGIN = %@", [textField text]);
}
- (void)textChanged:(NSNotification *)aNotification
{
NSLog(@"TEXT CHANGED = %@", [aNotification userInfo]);
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSLog(@"CHAR = %@", [textField text]);
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
NSLog(@"RETURN = %@", [textField text]);
[textField resignFirstResponder];
return YES;
}
UISwitch
-(void)viewDidLoad
{
UISwitch *aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 290, 300, 100)];
[self.view addSubview:aSwitch];
[aSwitch release];
[aSwitch setOn:YES];
[aSwitch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
}
- (void)switchAction:(UISwitch *)aSwitch
{
NSLog(@"SWITCH = %d", [aSwitch isOn]);
}
UISlider
-(void)viewDidLoad
{
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 320, 100, 100)];
[self.view addSubview:slider];
[slider release];
[slider setMaximumValue:100.0f];
[slider setMinimumValue:1.0f];
[slider setValue:50.0f];
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
}
- (void)sliderAction:(id)slider
{
NSLog(@"SLIDER = %f", [(UISlider *)slider value]);
}
UIImageView
-(void)viewDidLoad
{
UIImageView *anImageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 280, 200, 200)];
//[anImageView setImage:anImage];
[anImageView setImage:[UIImage imageNamed:@"CAMPUS TOUR BLACK.png"]];
[self.view addSubview:anImageView];
[anImageView setBackgroundColor:[UIColor purpleColor]];
[anImageView setContentMode:UIViewContentModeCenter];
[anImageView release];
NSArray *imagesArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"Images/bg_circle.png"], [UIImage imageNamed:@"CAMPUS TOUR BLACK.png"], nil];
[anImageView setAnimationImages:imagesArray];
[anImageView setAnimationDuration:0.5f];
[anImageView setAnimationRepeatCount:1];
[anImageView startAnimating];
//[anImageView stopAnimating];
//[anImageView isAnimating];
}
UIActivityIndicatorView
UIActivityIndicatorView *anActivityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect indicatorFrame = [anActivityIndicator frame];
indicatorFrame.origin = CGPointMake(200, 100);
anActivityIndicator.frame = indicatorFrame;
[anActivityIndicator setHidesWhenStopped:YES];
[anActivityIndicator startAnimating];
//[anActivityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
[self.view addSubview:anActivityIndicator];
[anActivityIndicator release];
UIProgressView
-(void)viewDidLoad
{
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
[self.view addSubview:progressView];
[progressView setTag:100];
[progressView setCenter:CGPointMake(200, 180)];
[progressView setProgress:0.5];
[progressView release];
[NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(progressBarChange:) userInfo:[NSMutableDictionary dictionaryWithObject:[NSNumber numberWithFloat:0] forKey:@"ProgressValue"] repeats:YES];
}
- (void)progressBarChange:(NSTimer *)aTimer
{
NSMutableDictionary *userInfo = [aTimer userInfo];
float progressValue = [[userInfo objectForKey:@"ProgressValue"] floatValue];
[(UIProgressView *)[self.view viewWithTag:100] setProgress:progressValue];
progressValue += 0.1;
if( progressValue > 1.1f)
{
[aTimer invalidate];
}
[userInfo setObject:[NSNumber numberWithFloat:progressValue] forKey:@"ProgressValue"];
}
UILabel
-(void)viewDidLoad
{
UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 80, 150, 100)];
[aLabel setText:@"Sample Label asdasd asd as da "];
[aLabel setNumberOfLines:0];
[aLabel setBackgroundColor:[UIColor redColor]];
[aLabel setTextAlignment:UITextAlignmentRight];
[self.view addSubview:aLabel];
[aLabel release];
}
UIButton
-(void)viewDidLoad
{
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[aButton setTitle:@"BUTTON" forState:UIControlStateNormal];
[aButton setFrame:CGRectMake(20, 180, 150, 100)];
[self.view addSubview:aButton];
[aButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchDown];
UIImage *anImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Images/bg_circle.png", [[NSBundle mainBundle] resourcePath]]];
//[aButton setImage:[UIImage imageNamed:@"Images/bg_circle.png"] forState:UIControlStateNormal];
[aButton setImage:anImage forState:UIControlStateNormal];
[anImage release];
}
- (void)buttonAction:(UIButton *)aButton
{
NSLog(@"BUTTON = %@", aButton);
[aButton setTitle:@"CLICKED" forState:UIControlStateNormal];
}
No comments:
Post a Comment