ok rather than try to explain my problem in text, watch this little video i recorded http://www.youtube.com/watch?v=fwb55jnZI6w
and here is the code for the detail view controller (the page where the webview is)
detailViewController.h
#import <UIKit/UIKit.h>
#import "MWFeedItem.h"
@interface DetailViewController : UIViewController <UIWebViewDelegate> {
MWFeedItem *item;
NSString *summaryString;
IBOutlet UILabel *titleLabel;
IBOutlet UIWebView *contentLabel;
//IBOutlet UILabel *dateLabel;
IBOutlet UIScrollView *textScroller;
}
@property (nonatomic, retain) MWFeedItem *item;
@property (nonatomic, retain) NSString *summaryString;
@property (nonatomic, retain) IBOutlet UILabel *titleLabel;
@property (nonatomic, retain) IBOutlet UIWebView *contentLabel;
@end
detailViewController.m
#import "DetailViewController.h"
#import "NSString+XMLEntities.h"
typedef enum { SectionHeader, SectionDetail } Sections;
typedef enum { SectionHeaderTitle, SectionHeaderDate, SectionHeaderURL } HeaderRows;
typedef enum { SectionDetailSummary } DetailRows;
@implementation DetailViewController
@synthesize item, summaryString, titleLabel, contentLabel;
- (BOOL)webView:(UIWebView *)contentLabel shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; {
NSURL *requestURL = [ [ request URL ] retain ];
// Check to see what protocol/scheme the requested URL is.
return [ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
return NO;
// Auto release
[ requestURL release ];
// If request url is something other than http or https it will open
// in UIWebView. You could also check for the other following
// protocols: tel, mailto and sms
}
- (void)viewDidLoad {
[super viewDidLoad];
/*if (item.date) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
self.dateString = [formatter stringFromDate:item.date];
[formatter release];
}*/
if (item.summary) {
self.summaryString = [[[item.summary stringByStrippingTags] stringByRemovingNewLinesAndWhitespace] stringByDecodingXMLEntities];
}
titleLabel.text = item.title ? item.title : @"[No Title]";
[titleLabel setBackgroundColor:[UIColor clearColor]];
//dateLabel.text = dateString ? dateString : @"[No Date]";
// Summary
NSString *HTMLData = summaryString;
[contentLabel loadHTMLString:HTMLData baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"http://www.feed43.com/1515171705611023.xml"]]];
//Calculate the expected size based on the font and linebreak mode of your label
//CGSize maximumLabelSize = CGSizeMake(280,9999);
//CGSize expectedLabelSize = [summaryString sizeWithFont:contentLabel.font
//constrainedToSize:maximumLabelSize
//lineBreakMode:contentLabel.lineBreakMode];
//adjust the label the the new height.
//CGRect newFrame = contentLabel.frame;
//newFrame.size.height = expectedLabelSize.height;
//contentLabel.frame = newFrame;
[textScroller setCanCancelContentTouches:NO];
[textScroller setContentSize:CGSizeMake(320, 500)];
textScroller.indicatorStyle = UIScrollViewIndicatorStyleBlack;
textScroller.scrollEnabled = YES;
textScroller.clipsToBounds = YES;
//return titleLabel;
//return dateLabel;
//return contentLabel;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return NO;
}
- (void)dealloc {
[super dealloc];
}
@end
note: even though it says "contentLabel" it is a UIWebView. it is left over from old versions
Thanks!