以下均为使用到Xib文件,其中原因大家应当都知道,不再赘述。
1、显示图像Image View
1. CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f); 2. UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; 3. [myImage setImage:[UIImage imageNamed:@"myImage.png"]]; 4. myImage.opaque = YES; // 设置不透明度 5. [self.view addSubview:myImage]; 6. [myImage release];?
2、Web view
1. CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0); 2. UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame]; 3. [webView setBackgroundColor:[UIColor whiteColor]]; 4. NSString *urlAddress = @"http://www.google.com"; 5. NSURL *url = [NSURL URLWithString:urlAddress]; 6. NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 7. [webView loadRequest:requestObj]; 8. [self addSubview:webView]; 9. [webView release];?