RSSリーダーを含むものを構築しています。すべての説明 (以下のコードを使用して RSS フィードから取得) を除いて、すべて正常に動作しているように見えますが、説明の前に "
「どうやって取り除くの?
#import "RSSItem.h"
#import "GTMNSString+HTML.h"
@implementation RSSItem
-(NSAttributedString*)cellMessage
{
if (_cellMessage!=nil) return _cellMessage;
NSDictionary* boldStyle = @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica-Bold" size:16.0]};
NSDictionary* normalStyle = @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:16.0]};
NSMutableAttributedString* articleAbstract = [[NSMutableAttributedString alloc] initWithString:self.title];
[articleAbstract setAttributes:boldStyle
range:NSMakeRange(0, self.title.length)];
[articleAbstract appendAttributedString:
[[NSAttributedString alloc] initWithString:@"\n\n"]
];
int startIndex = [articleAbstract length];
NSString* description = [NSString stringWithFormat:@"%@<p><p><em>...", [self.description substringToIndex:200]];
description = [description gtm_stringByUnescapingFromHTML];
[articleAbstract appendAttributedString:
[[NSAttributedString alloc] initWithString: description]
];
[articleAbstract setAttributes:normalStyle
range:NSMakeRange(startIndex, articleAbstract.length - startIndex)];
_cellMessage = articleAbstract;
return _cellMessage;
}
@end
これは、RSS フィードを表示する MasterViewController.m ファイルのコードです。
#import "MasterViewController.h"
#import "DetailViewController.h"
#import "TableHeaderView.h"
#import "RSSLoader.h"
#import "RSSItem.h"
@interface MasterViewController () {
NSArray *_objects;
NSURL* feedURL;
UIRefreshControl* refreshControl;
}
@end
@implementation MasterViewController
-(void)refreshFeed
{
RSSLoader* rss = [[RSSLoader alloc] init];
[rss fetchRssWithURL:feedURL
complete:^(NSString *title, NSArray *results) {
dispatch_async(dispatch_get_main_queue(), ^{
[(TableHeaderView*)self.tableView.tableHeaderView setText:title];
_objects = results;
[self.tableView reloadData];
[refreshControl endRefreshing];
});
}];
}
-(void)viewDidLoad
{
[super viewDidLoad];
feedURL = [NSURL URLWithString:@"http://pipes.yahoo.com/pipes/pipe.run?_id=c47dcdc375e72c5ad08f3470eea6afa0&_render=rss"];
refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self
action:@selector(refreshInvoked:forState:)
forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview: refreshControl];
[self refreshFeed];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
RSSItem *item = [_objects objectAtIndex:indexPath.row];
CGRect cellMessageRect = [item.cellMessage boundingRectWithSize:CGSizeMake(200,10000)
options:NSStringDrawingUsesLineFragmentOrigin
context:nil];
return cellMessageRect.size.height;
}
-(void) refreshInvoked:(id)sender forState:(UIControlState)state {
[self refreshFeed];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _objects.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
RSSItem *object = _objects[indexPath.row];
cell.textLabel.attributedText = object.cellMessage;
cell.textLabel.numberOfLines = 5;
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
RSSItem *object = _objects[indexPath.row];
self.detailViewController.detailItem = object;
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSDate *object = _objects[indexPath.row];
[[segue destinationViewController] setDetailItem:object];
}
}
-(IBAction)btn_regPressed:(id)sender
{
NSLog(@"start to dissmis modal");
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
何が起こっているのですか?