开发学院手机开发iPhone 开发 常用 IPHONE 编程 基础代码 阅读

常用 IPHONE 编程 基础代码

 2010-03-10 16:08:00 来源:WEB开发网   
核心提示:LoggingIn Xcode, click Run > Console to see NSLog statements.NSLog(@"log: %@ ", myString);NSLog(@"log: %f ", myFloat);NSLog(@"log: %

Logging

In Xcode, click Run > Console to see NSLog statements.

NSLog(@"log: %@ ", myString);

NSLog(@"log: %f ", myFloat);

NSLog(@"log: %i ", myInt);

Display Images

Display an image anywhere on the screen, without using UI Builder. You can use this for other types of views as well.

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;

// explicitly opaque for performance

[self.view addSubview:myImage];

[myImage release];

Web view

A basic UIWebView.

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];

[webView release];

Display the Network Activity Status Indicator

This is the rotating icon displayed on the iPhone status bar in the upper left to indicate there is background network activity taking place.

UIApplication* app = [UIApplication sharedApplication];

app.networkActivityIndicatorVisible = YES; // to stop it, set this to NO

Animation: Series of images

Show a series of images in succession

NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"myImage1.png"], [UIImage imageNamed:@"myImage2.png"], [UIImage imageNamed:@"myImage3.png"], [UIImage imageNamed:@"myImage4.gif"], nil];

1 2 3 4 5  下一页

Tags:常用 IPHONE 编程

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
更多精彩
    赞助商链接

    热点阅读
      焦点图片
        最新推荐
          精彩阅读