Skip to content

Instantly share code, notes, and snippets.

@thanhtungka91
Last active December 4, 2017 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thanhtungka91/7250a795ccc54468f127a611986c2ca5 to your computer and use it in GitHub Desktop.
Save thanhtungka91/7250a795ccc54468f127a611986c2ca5 to your computer and use it in GitHub Desktop.
webview
- (void)openPdfWebview:(NSString *)linkUrl
{
pdfWebViewController= [[PdfWebViewController alloc] initWithNibName:@"PdfWebViewController" bundle:[NSBundle mainBundle]];
[pdfWebViewController setupUrlLink:linkUrl];
[pdfWebViewController.view setFrame:CGRectMake(0, 0, sview.view.frame.size.width, sview.view.frame.size.height)];
sview.view.userInteractionEnabled = true;
[sview.view addSubview:pdfWebViewController.view];
[pdfWebViewController viewWillAppear:NO];
[UIView animateWithDuration:0.5f animations:^{ [pdfWebViewController.view setAlpha:1.0f]; } completion:nil];
}
#import <UIKit/UIKit.h>
@interface PdfWebViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIWebView *webview;
@property (strong, nonatomic) IBOutlet UIView *mainview;
@property (strong, nonatomic) NSString *urlpdfLink;
-(void)setupUrlLink:(NSString*)urlLink;
@end
#import "PdfWebViewController.h"
@interface PdfWebViewController ()
@end
@implementation PdfWebViewController
@synthesize webview;
@synthesize mainview;
- (void)viewDidLoad {
self.view.userInteractionEnabled = true;
mainview.userInteractionEnabled = true;
[self becomeFirstResponder];
[super viewDidLoad];
[self loadWeview];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)loadWeview{
// NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
// NSString *url = self.urlpdfLink;
NSURL *nsurl=[NSURL URLWithString:self.urlpdfLink];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
[webview setFrame:CGRectMake(0, 0, mainview.frame.size.width, mainview.frame.size.height-40)];
[mainview addSubview:webview];
}
-(void)setupUrlLink:(NSString*)urlLink{
self.urlpdfLink = urlLink;
}
- (IBAction)tapClose:(id)sender {
[UIView animateWithDuration:0.2f
delay:0.0f
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.view setAlpha:0.0f];
}
completion:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment