1

While implementing a web-view into the page I coded like the following

 _testURLString = @"http://192.168.4.196/course/Course";
NSString *embedHTML = [NSString stringWithFormat:@"\
                       <html><head>\
                       <style type=\"text/css\">\
                       body {\
                       background-color: transparent;\
                       color: blue;\
                       }\
                       </style>\
                       </head><body style=\"margin:0\">\
                       <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                       width=\"400\" height=\"700\"></embed>\
                       </body></html>"];
NSString *html = [NSString stringWithFormat:embedHTML, _testURLString, 400, 700];

UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];

videoView.backgroundColor = [UIColor clearColor];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];

The warning X-code through is more '%' conversions than data arguments warning at the

src=\"%@\"

I don't know what to do please help me.

4 Answers 4

1

You are using stringWithFormat: , and this method was supposed to replace src=\"%@\" for another string, but you are not passing none.

It should be something like this:

NSString *embedHTML = [NSString stringWithFormat:@"\
                   <html><head>\
                   <style type=\"text/css\">\
                   body {\
                   background-color: transparent;\
                   color: blue;\
                   }\
                   </style>\
                   </head><body style=\"margin:0\">\
                   <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                   width=\"400\" height=\"700\"></embed>\
                   </body></html>", _testURLString]; //or something else
Sign up to request clarification or add additional context in comments.

Comments

0

You need to pass src (src=\"%@\") value in this string. For more info see in last line

 NSString *embedHTML = [NSString stringWithFormat:@"\
                           <html><head>\
                           <style type=\"text/css\">\
                           body {\
                           background-color: transparent;\
                           color: blue;\
                           }\
                           </style>\
                           </head><body style=\"margin:0\">\
                           <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                           width=\"400\" height=\"700\"></embed>\
                           </body></html>",_testURLString];     // Edited  

Comments

0

You can eliminate the second formatted string entirely seeing as it didn't actually do anything of value. Additionally, you never added format specifiers for the URL and the width/height of the video in the initial formatted string. Here's an example:

NSString *embedHTML = [NSString stringWithFormat:@"\
                       <html><head>\
                       <style type=\"text/css\">\
                       body {\
                       background-color: transparent;\
                       color: blue;\
                       }\
                       </style>\
                       </head><body style=\"margin:0\">\
                       <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                       width=\"%i\" height=\"%i\"></embed>\
                       </body></html>",_testURLString,400,700];

Comments

0

Edit width=\"400\" height=\"700\" to width=\"%d\" height=\"%d\" since you're passing the arguments later in the build up of your HTML String.

Also, as 0x7fffffff said, if you're just making a simple string then write your embedHTML as @"your_string" instead of [NSString stringWithString:@"your_string"]; XCode nowadays warns for this redundancy.

1 Comment

can you type in the exact warning ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.