Last active
December 4, 2017 09:36
-
-
Save thanhtungka91/7250a795ccc54468f127a611986c2ca5 to your computer and use it in GitHub Desktop.
webview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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