2010-02-24 18 views
6

में पोर्ट्रेट और लैंडस्केप दृश्य में स्वचालित रूप से आकार बदलता है। मैं आईफोन विकास के लिए नया हूं। मेरे ऐप में, मैं सी पोर्ट्रेट ओरिएंटेशन के साथ डिवाइस में वेब व्यू प्रदर्शित करना चाहता हूं। इसे लैंडस्केप ओरिएंटेशन का भी समर्थन करना चाहिए। मैंने नीचे दी गई विधि का उपयोग किया लेकिन कोई अपेक्षित आउटपुट नहीं है।वेबव्यू आईफोन

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

return (interfaceOrientation == UIInterfaceOrientationPortrait || 

interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == 

UIInterfaceOrientationLandscapeRight); 
} 

मार्गदर्शन कृपया मेरी तरफ मुझे out.Thanks मदद

उत्तर

10

मैं तुम्हें webview.That के लिए तय फ्रेम निर्धारित किया है, जबकि उन्मुखीकरण chage

को लागू करने का प्रयास करें यह मदद नहीं करेगा लगता है आपके यूआरएल के साथ ओवरफ्लो यूआरएल;

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

उन्मुखीकरण

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

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

साथ उन्मुखीकरण

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

} 

वेब-व्यू बदलाव के लिए समर्थन करने के लिए आशा है कि इसके बाद के संस्करण अपनी आवश्यकता को पूरा करेगा। सभी बेहतरीन।

+0

धन्यवाद। मैं अपने वेबव्यू में टूलबार प्रदर्शित करना चाहता हूं? इसे कैसे प्राप्त किया जा सकता है?। मैं अपने वेबव्यू में टूलबार नहीं देख पा रहा हूं। – Pugal

+0

@pugal टैब बार को सबव्यू के रूप में सम्मिलित करें ... [self.view insertSubview: tBar नीचे सबव्यूव्यू: सामग्री दृश्य]; आपके द्वारा उपयोग किए गए टूलबार में tbar को बदलें। – Warrior

0

आप तो बस लौट YES किसी भी अभिविन्यास समर्थन करना चाहते हैं। वेब view.Change ढेर प्रदर्शित करने के लिए

उपयोग इस कोड:

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

यह आईओएस 6 में बहिष्कृत किया गया था: https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#jumpTo_9 – poshaughnessy

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^