質問

私は私のアプリdevelopment.In iphoneに新しいです、私はC肖像Orientation.Itを持つデバイスでWeb表示も横向きをサポートする必要があります表示したいです。私は法の下に使用されるが、何も予想される出力はありません。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{

return (interfaceOrientation == UIInterfaceOrientationPortrait || 

 interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == 

UIInterfaceOrientationLandscapeRight);
}

me.Pleaseヘルプを案内してください私out.Thanks

役に立ちましたか?

解決

私はあなたがwebview.Thatのために、固定枠を設定していると思われますない助けオリエンテーションを実施しながら、チャゲ

このお試しください

を使用するウェブview.ChangeあなたのURLと、スタックオーバーフローのURLを表示するため、このコード;

contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
self.view.autoresizesSubviews = YES;


CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y -= 20.0;

webView = [[UIWebView alloc] initWithFrame:webFrame];

[contentView addSubview:webView]; 
webView.scalesPageToFit = YES;
webView.autoresizesSubviews = YES;
webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[webView setBackgroundColor:[UIColor clearColor]];
NSString *urlAddress = @"https://www.stackoverflow.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
webView.delegate =self;
[webView release];

方位をサポートするために、

   - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{
return YES;

}

方位でWebビューの変更については、

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if(fromInterfaceOrientation == UIInterfaceOrientationPortrait){
 [webView stringByEvaluatingJavaScriptFromString:@"rotate(0)"];

}
else{
    [webView stringByEvaluatingJavaScriptFromString:@"rotate(1)"];
}
}

希望上記はあなたの条件を満足させます。 すべての最高ます。

他のヒント

あなたが任意の方向をサポートしたい場合は、単にYESを返します。

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{
    return YES;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top