0

基本的にWebページをロードするアプリ(iPhoneとiPadのユニバーサル)を実現しています。iPhone の WebView は正しく読み込まれていますが、iPad の WebView は何もしていません?!

ここに私のViewController.mがあります

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIWebView *webViewiPad;

@end

@implementation ViewController
@synthesize webView = _webView;
@synthesize webViewiPad = _webViewiPad;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.at"]]];
    [self.webViewiPad loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.at"]]];
}
4

1 に答える 1

0

ViewControllerがロードされたら、次のようにします。

 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

   self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
  }
 else
 {
   self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
 }

webViewiPadをiPadXibにバインドし、webViewをiPhoneXibにそれぞれバインドします

 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //load differnt xib according to iphone and ipad
{
    [self.webViewiPad loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.at"]]];

 }
 else
 {
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.at"]]];

 }
于 2012-09-01T12:24:12.633 に答える