Reputation: 869
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.
Upvotes: 1
Views: 147
Reputation: 1299
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.
Upvotes: 0
Reputation: 130193
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];
Upvotes: 0
Reputation: 11675
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
Upvotes: 1
Reputation: 17535
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
Upvotes: 0