2011-05-12 2 views
0

내 앱에서 rss 피드가 작동하지만 각 article의 모든 텍스트가 표시되지 않습니다. uiwebview에 표시해야하는 텍스트의 절반 만 표시합니다. 텍스트를 많이 표시하도록 할 여지가 있습니까? 필자는 잠시 동안 코드를 둘러 보았고 그것을 이해하지 못하는 것 같습니다. 어떤 제안을 환영합니까?
TABLEVIEW.Hiphone 앱에서 RSS 피드의 전체 텍스트를 표시하려고합니다

@class NewsreelViewController; 

    @interface ClubNewsTableView : UITableViewController {UITableViewDelegate,  UITableViewDataSource} { 
     UIActivityIndicatorView *activityIndicator;  
    NSArray *items; 
    IBOutlet UITableView *clubNewsTableView; 
    NSMutableArray *clubNewsArray; 
    NewsreelViewController *newsreelViewController; 
    } 
    @property (nonatomic, retain) NSMutableArray *clubNewsArray; 
    @property (nonatomic, retain) NewsreelViewController *newsreelViewController; 
    @property (retain, nonatomic) UIActivityIndicatorView *activityIndicator;  
    @property (retain, nonatomic) NSArray *items;  
    @end 

TABLEVIEW.M

@interface ClubNewsTableView (PrivateMethods)  
    - (void)loadData;  
    @end  


    @implementation ClubNewsTableView 
    @synthesize clubNewsArray; 
    @synthesize newsreelViewController; 
    @synthesize activityIndicator, items; 

    - (id)initWithStyle:(UITableViewStyle)style 
    { 
    self = [super initWithStyle:style]; 
    if (self) { 
    // Custom initialization 

    } 
    return self;  
    } 

    - (void)dealloc 
    { 
    [activityIndicator release];  
    [items release]; 
    [clubNewsArray release]; 
    [super dealloc]; 
    } 

    - (void)didReceiveMemoryWarning 
    { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
    } 


    - (void)viewDidLoad 
    { 
     [super viewDidLoad]; 

     // Uncomment the following line to preserve selection between presentations. 
     // self.clearsSelectionOnViewWillAppear = NO; 

     // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
     // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
     UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];  
     indicator.hidesWhenStopped = YES;  
     [indicator stopAnimating];  
     self.activityIndicator = indicator;  
     [indicator release];  

     UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:indicator];  
     self.navigationItem.rightBarButtonItem = rightButton;  
     [rightButton release];  
    } 

    - (void)viewDidUnload 
    { 
     [super viewDidUnload]; 
     self.clubNewsArray = nil; 
     // Release any retained subviews of the main view. 
     // e.g. self.myOutlet = nil; 
    } 

    - (void)viewWillAppear:(BOOL)animated 
    { 
     [super viewWillAppear:animated]; 
    } 

    - (void)viewDidAppear:(BOOL)animated 
    { 
     [self loadData]; 
     [super viewDidAppear:animated]; 
    } 

    - (void)loadData {  
     if (items == nil) {  
      [activityIndicator startAnimating];  

      Parser *rssParser = [[Parser alloc] init];  
      [rssParser parseRssFeed:@"http://www.clontarfrugby.com/feed/" withDelegate:self];  

      [rssParser release];  

     } else {  
      [self.tableView reloadData];  
     }  

    }  

    - (void)receivedItems:(NSArray *)theItems {  
     items = theItems;  
     [self.tableView reloadData];  
     [activityIndicator stopAnimating];  
    }  

    - (void)viewWillDisappear:(BOOL)animated 
    { 
     [super viewWillDisappear:animated]; 
    } 

    - (void)viewDidDisappear:(BOOL)animated 
    { 
     [super viewDidDisappear:animated]; 
    } 

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    { 
     // Return YES for supported orientations 
     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    } 

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
    { 
    //#warning Potentially incomplete method implementation. 
     // Return the number of sections. 
     return 1; 
    } 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 
    //#warning Incomplete method implementation. 
     // Return the number of rows in the section. 
     return [items count]; 
    } 

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     static NSString *CellIdentifier = @"Cell"; 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) { 
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
     } 

     // Configure the cell... 
     cell.textLabel.text = [[items objectAtIndex:indexPath.row] objectForKey:@"title"];  
     cell.detailTextLabel.text = [[items objectAtIndex:indexPath.row] objectForKey:@"date"];  

     NSString *imageName = [[items objectAtIndex:indexPath.row] objectForKey:@"image"]; 
     UIImageView *titleImage = (UIImageView *)[cell viewWithTag:2]; 
     UIImage *image = [UIImage imageNamed:imageName];  
     [titleImage setImage:image]; 


     // Format date  
     NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];  
     [dateFormatter setDateStyle:NSDateFormatterMediumStyle];  
     [dateFormatter setTimeStyle:NSDateFormatterNoStyle];  
     //cell.detailTextLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]description]; 
     //cell.detailTextLabel.text = [[items objectAtIndex:indexPath.row] objectForKey:@"date"];  
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;  
     return cell;  
    } 

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath   *)indexPath 
    { 
     // Navigation logic may go here. Create and push another view controller. 
     /* 
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; 
     // ... 
     // Pass the selected object to the new view controller. 
     [self.navigationController pushViewController:detailViewController animated:YES]; 
     [detailViewController release]; 
     */ 

     NSDictionary *theItem = [items objectAtIndex:indexPath.row];  
     NewsreelViewController *nextController = [[NewsreelViewController alloc] initWithNibName:@"NewsreelViewController" bundle:nil]; 
     nextController.item=theItem;  
     [self.navigationController pushViewController:nextController animated:YES];  
     [nextController release]; 

    } 

    @end 

DETAILVIEW.H

 #import <UIKit/UIKit.h> 


    @interface NewsreelViewController : UIViewController { 
NSDictionary *item; 
IBOutlet UILabel *itemTitle; 
IBOutlet UILabel *itemDate; 
IBOutlet UIWebView *itemSummary; 
IBOutlet UIWebView *itemImage; 
    } 

    @property (retain, nonatomic) NSDictionary *item; 
    @property (retain, nonatomic) IBOutlet UILabel *itemTitle; 
    @property (retain, nonatomic) IBOutlet UILabel *itemDate; 
    @property (retain, nonatomic) IBOutlet UIWebView *itemSummary; 
    @property (retain, nonatomic) IBOutlet UIWebView *itemImage; 

    - (id)initWithItem:(NSDictionary *)theItem; 

    @end 

DETAILVIEW.M

@implementation NewsreelViewController 
    @synthesize item, itemTitle, itemDate, itemSummary, itemImage; 
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
    { 
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
     if (self) { 
      // Custom initialization 
     } 
     return self; 
    } 

    - (void)dealloc 
    { 
     [item release]; 
     [itemTitle release]; 
     [itemDate release]; 
     [itemSummary release]; 
     [itemImage release]; 
     [super dealloc]; 
    } 

    - (void)didReceiveMemoryWarning 
    { 
     // Releases the view if it doesn't have a superview. 
     [super didReceiveMemoryWarning]; 

     // Release any cached data, images, etc that aren't in use. 
    } 

    #pragma mark - View lifecycle 

    - (id)initWithItem:(NSDictionary *)theItem { 
     if (self = [super initWithNibName:@"Detail" bundle:nil]) { 
      self.item = theItem; 
      self.title = [item objectForKey:@"title"]; 
     } 

     return self; 
    } 

    - (void)viewDidLoad { 
     [super viewDidLoad]; 

     self.itemTitle.text = [item objectForKey:@"title"]; 

     NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];  
     [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; 
     [dateFormatter setTimeStyle:NSDateFormatterNoStyle]; 

     self.itemDate.text = [item objectForKey:@"date"]; 
     [self.itemImage loadHTMLString:[item objectForKey:@"image"] baseURL:nil]; 
     [self.itemSummary loadHTMLString:[item objectForKey:@"summary"] baseURL:nil]; 
    } 

    - (void)viewDidUnload 
    { 
     [super viewDidUnload]; 
     // Release any retained subviews of the main view. 
     // e.g. self.myOutlet = nil; 
    } 

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    { 
     // Return YES for supported orientations 
     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    } 
    @end 

답변

0

당신이 내용을 표시하는 경우 시도해보십시오. 그러면

webview.scalesPageToFit = YES; 

모두 최고입니다.

+0

아니요 완벽하게 그냥 모든 텍스트를 표시하지 않을 수 있습니다. 텍스트는 텍스트의 나머지 부분에 대해 여전히 절반 정도 theres 여전히 중지하지만 그냥 표시되지 않습니다. – user643160

+0

코드를 게시 할 수 있습니까? 내가하고있는 일을 정확히 알지 못하니? – Warrior

+0

내 테이블보기 및 위의 내 세부 정보보기 코드를 추가했습니다. 내 파서 코드도 확인하고 싶습니까? 그리고 그 itemSummary는 완전히 표시되지 않을 것입니다. – user643160

관련 문제