Tuesday, 12 February 2013

Implement a .rtf or .doc file Show in WebView (Xcode)

Add the which Any Format File (doc,rtf,.....etc) you want shown in WebView.


.h File:


@interface LocalFileWebView : UIViewController
{
    IBOutlet UIWebView *Webviewlocal;
}

@property(nonatomic,retain) IBOutlet NSString *Name;

@end



.m File:

@synthesize Name;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title=@"TamilNadu Details";
    
    self.Name=@"Tamilnadu";
    
    NSString *path=[[NSBundle mainBundle] pathForResource:self.Name ofType:@"rtf"];
    NSURL *url=[NSURL fileURLWithPath:path];
    NSURLRequest *req=[NSURLRequest requestWithURL:url];
    [Webviewlocal loadRequest:req];
}


Output:


         Map the WebView and Run the Application.






No comments: