Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I am working on a blog app. I parse the RSS feed and then take one of the item elements and build html string. I have to leave the UIWebView Scales To Fit turned off, or the text all gets shoved into one page, and is too small to read. If I turn on scales to fit on the UIWebView, the text is perfect, but if larger pictures are in the blog, they stretch well off the width of the page. One such picture is

img class="aligncenter size-full wp-image-4532" title="Father_and_daughter_1" src="http://treymorgan.net/wp-content/uploads/2012/06/Father_and_daughter_1.jpg" alt="" width="590" height="342" /

In this case, the width goes well beyond 320px. Is there any way I could use regex or something to detect if the width is greater than 320, and if so, have it replace the width and height by something that would fit?
 
Change numbers in NSString

I'm having an issue with replacing string by occurence of string methods
The string I want to change is:

<img class="alignleft size-full wp-image-4539" title="divorce" src="http://treymorgan.net/wp-content/uploads/2012/06/divorce.jpg" alt="" width="226" height="170" />

All I want to do is replace the width and height numbers to a standard set...any suggestions?
 
Here's an example of use for the occurrences of string method:

NSString *string = @"I am crying from happiness";
string = [string stringByReplacingOccurrencesOfString:mad:"happiness" withString:mad:"a beating in an alley way!"];

NSLog(@"%@",string);

So just substitute the occurrences you'd like to change in.

Thanks,
 
Have a look at NSString method
Code:
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet options:(NSStringCompareOptions)mask range:(NSRange)aRange

Set it to search backwards with a Numeral Character set and the range set firstly to the full string. That should return a range for the characters that describe the height. Which you could then mutate. Then on the second pass reduce the search range so that it all the string before the first find and that should get you the range of the characters that describe the width.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.