2013-06-17 11 views
6

मुझे अपने iOS application.For में यूट्यूब वीडियो एम्बेड करने कि मैं एक UIWebView & बनाया है hereलोड HTMLString का उपयोग कर UIWebView में HTML स्ट्रिंग लोड करने में असमर्थ: आईओएस में baseURL?

मैं ऊपर समस्या के लिए सभी उत्तर के माध्यम से चले गए हैं निम्नलिखित से Youtube वीडियो लोड करने की कोशिश कोशिश कर रहा हूँ। फिर भी यह काम नहीं कर रहा है। मैं भी फिर भी बहुत ही सरल HTML

NSString *embedHTML =[NSString stringWithFormat:@"<html><body>Hello World</body></html>"]; 
[webView loadHTMLString:embedHTML baseURL:nil]; 

लोड हो रहा है की कोशिश की है, मैं त्रुटि संकलन Parse Issue Expecte ']'

मैं कोशिश की है सफाई हो रही है, XCode & इसे फिर से दोबारा लॉन्च छोड़ने। मैं नहीं, मैं उस विधि का उपयोग करने में सक्षम नहीं हूँ। मेरे UIWebView के लिए उपरोक्त loadHTMLString विधि का उपयोग कैसे करें।

पीएस: कृपया इस प्रश्न को डुप्लिकेट के रूप में टैग न करें। मैंने Stackoverflow में सभी समाधानों का प्रयास किया है। कुछ भी काम नहीं किया है

+0

डिबगिंग के अलावा सब कुछ किया? वेबव्यू के फ्रेम को लॉग करें और इसे यहां –

+0

@ LithuT.V जोड़ें .. मैं कोड को संकलित करने में भी सक्षम नहीं हूं। यह एक संकलन समय त्रुटि है। – Bharath

+0

टिप्पणी करते हैं कि कौन सी रेखा कोड संकलित करती है? –

उत्तर

0

यदि आप लोगों की मदद करना चाहते हैं तो आपको शायद अधिक कोड प्रदान करने की आवश्यकता है। मैंने अभी भी वेब व्यू का एक ही तरीके से उपयोग किया है और यह ठीक काम कर रहा है।

self.webView = [[UIWebView alloc] initWithFrame:myFrame]; 
self.webView.scalesPageToFit = YES; 
[self.webView setBackgroundColor:[UIColor whiteColor]]; 

//pass the string to the webview 
[self.webView loadHTMLString:[[self.itineraryArray objectAtIndex:indexPath.row] valueForKey:@"body"] baseURL:nil]; 

//add it to the subview 
[self.view addSubview:self.webView]; 

क्या आप अधिक जानकारी और कोड प्रदान कर सकते हैं?

+0

यह मैंने किया है 'UIWebView * webView = [[UIWebView alloc] initWithFrame: myFrame]; एनएसएसटींग * एम्बेड एचटीएमएल = [एनएसएसटींग स्ट्रिंगविथफॉर्मैट: @ " हैलो वर्ल्ड"]; [वेब दृश्य लोड HTMLString: एम्बेड HTML आधार: शून्य]; ' यह बात करता है, मैंने यही किया। मुझे संकलन समय त्रुटि मिल रही है। वह 'loadHTMLString' विधि स्वयं काम नहीं कर रही है। भले ही सबकुछ सही है, यह 'पार्स इश्य्यू एक्सपेपेक्ट'] '' को संकलित त्रुटि – Bharath

+0

के रूप में दिखा रहा है क्या आप सुनिश्चित हैं कि त्रुटि वेब व्यू से है? यदि आप वेब व्यू लाइनों पर टिप्पणी करते हैं, तो त्रुटि गायब हो जाती है? क्या आप मुख्य दृश्य में वेबव्यू जोड़ रहे हैं? – Mike

+0

हां। समस्या वेबव्यू के साथ है। अगर मैं उस पंक्ति पर टिप्पणी करता हूं, तो सब कुछ ठीक काम कर रहा है। खुद को जोड़ने से पहले मुझे त्रुटि मिल रही है। – Bharath

0

यह does not webview.Please पर एक मुद्दा की तरह लगता है, जहां यह breaks.Error कहते हैं आप कोड

+0

@ लिथु टीवी ..नहीं, नहीं क्योंकि मैंने '] छोड़ा था। मैंने एक नई परियोजना भी बनाई है और वहां मैंने एक ही पंक्ति लिखी है। मैं इसे पेस्ट कॉपी भी करता हूं। मैंने मैन्युअल रूप से सबकुछ टाइप किया है। फिर भी अन्य प्रोजेक्ट में भी एक ही त्रुटि :-( – Bharath

+0

आप किस लाइन के बारे में बात कर रहे हैं ?? –

+0

वेबव्यू फ्रेम कृपया? वेबव्यू की भी वैध मेमोरी है। ठीक से कनेक्ट हो गया है। कोड मुझे ठीक लगता है –

5
WebView *webDesc = [[UIWebView alloc]initWithFrame:CGRectMake(12, 50, 276, 228)]; 

NSString *embedHTML = @"<html><head></head><body><p>1. You agree that you will be the technician servicing this work order?.<br>2. You are comfortable with the scope of work on this work order?.<br>3. You understand that if you go to site and fail to do quality repair for any reason, you will not be paid?.<br>4. You must dress business casual when going on the work order.</p></body></html>"; 

webDesc.userInteractionEnabled = NO; 
webDesc.opaque = NO; 
webDesc.backgroundColor = [UIColor clearColor]; 
[webDesc loadHTMLString: embedHTML baseURL: nil]; 
1
- (NSString *)getHTMLContent 
{ 
    NSString *cssPath = [[NSBundle mainBundle] pathForResource:@"baseline" ofType:@"css"]; 

    NSData *cssData = [NSData dataWithContentsOfFile:cssPath]; 
    NSString *cssStyle = [[NSString alloc] initWithData:cssData encoding:NSASCIIStringEncoding]; 

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
    [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; 

    NSString *subtitle = [NSString stringWithFormat:@"%@ | %@", self.article.author, [dateFormatter stringFromDate:self.article.publishedDate]]; 

    NSString *htmlString = [NSString stringWithFormat:@"<html><head><meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'></head><style type=\"text/css\">%@</style><body><div id=\"container\"><h1>%@</h1><p class='subtitle'>%@</p>%@</div></body></html>", cssStyle, self.article.title, subtitle, self.article.content]; 

    return htmlString; 
} 
1

यह बहुत सरल है में कहीं एक ] याद कोड जोड़ कर। आप को केवल एक पंक्ति जोड़नी है। और यहाँ यह है। यूआरएल वेबव्यू में सीधे लोड करने के लिए प्रयास करें यह

NSString *htmlString = @"<html><head></head><body><p>1. You agree that you will be the technician servicing this work order?.<br>2. You are comfortable with the scope of work on this work order?.<br>3. You understand that if you go to site and fail to do quality repair for any reason, you will not be paid?.<br>4. You must dress business casual when going on the work order.</p></body></html>"; 
[WebView loadHTMLString: htmlString baseURL: nil]; 
-2

कोशिश:

UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(100, 100, 200, 250)]; 

[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://youtube.com/embed/-0Xa4bHcJu8"]]]; 
+0

उत्तर प्रश्न से संबंधित नहीं है –

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