Created
October 3, 2012 17:52
-
-
Save solsolomon/3828587 to your computer and use it in GitHub Desktop.
IPhone Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Web View | |
CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0); | |
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame]; | |
[webView setBackgroundColor:[UIColor whiteColor]]; | |
NSString *urlAddress = @"http://www.google.com"; | |
NSURL *url = [NSURL URLWithString:urlAddress]; | |
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; | |
[webView loadRequest:requestObj]; | |
[self addSubview:webView]; | |
//Display Images | |
CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f); | |
UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; | |
[myImage setImage:[UIImage imageNamed:@"myImage.png"]]; | |
myImage.opaque = YES; | |
//Timer | |
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(myMethod) userInfo:nil repeats:YES]; | |
//then receive parameters from the user info: | |
-(void)myMethod:(NSTimer*)timer { // Now I can access all the properties and methods of myObject [[timer userInfo] myObjectMethod]; } | |
//to stop a timer: | |
[myTimer invalidate]; | |
myTimer = nil; | |
//Fade In | |
-(void)fadeIn:(UIView*)viewToFadeIn withDuration:(NSTimeInterval)duration andWait:(NSTimeInterval)wait | |
{ | |
[UIView beginAnimations: @"Fade In" context:nil]; | |
[UIView setAnimationDelay:wait]; | |
[UIView setAnimationDuration:duration]; | |
viewToFadeIn.alpha = 1; | |
[UIView commitAnimations]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment