About PDF vertical sliding from page to page in iOS - iphone

I am work on an app that can make PDF vertical sliding in iOS using CGPDFDocumentRef.
Now i can display one page PDF perfectly, but I don't know how can make it vertical sliding from page to page.
Can anyone help me? Give me an idea or sample,thank you
Sorry for my poor English.

add UIWebView in WebViewViewController.xib and connect that.Implement same as i have posted.
#interface WebViewViewController : UIViewController<TapDetectingWindowDelegate>
{
}
#property (strong, nonatomic) IBOutlet UIWebView *mWebView;
#end
#implementation WebViewViewController
#synthesize mWebView;
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:#"EventHandlingiPhoneOS"
ofType:#"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mWebView loadRequest:request];
}

This is the best PDF library you could integrate and implement PDF view horizontally.
https://github.com/vfr/Reader

Why don't you use UIWebView for showing the PDF file?
It is very simple and easy to use it!
However, if you really want to make your custom viewer, you can use UIScrollView for it.
like this:
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,640)];
[self.view addSubview:scroll];
view1.frame = CGRectMake(0,0,320,640);
view2.frame = CGRectMake(0,320,320,640);
view3.frame = CGRectMake(0,640,320,640);
[scroll addSubview:view1];
[scroll addSubview:view2];
[scroll addSubview:view3];
scroll.contentSize = CGSizeMake(320, 960);
[scroll release];

Related

UIWebview scalesPageToFit doesn't work perfectly

I'm using a small UIWebView, and scalesPageToFit doesn't work correctly for some url. (look like it cannot resize at 100%. (but if i zoom out the webview manually(gesture), it work!
view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 400.0f)];
webViewT = [[UIWebView alloc] initWithFrame:view.bounds];
webViewT.delegate = self;
webViewT.scalesPageToFit = YES;
NSURL* url = [NSURL URLWithString:#"http://www.google.com/"];
[webViewT loadRequest:[NSURLRequest requestWithURL:url]];
Please note that i've found a solution:(below work, BUT I have the time to see a "resize"
- (void) webViewDidFinishLoad:(UIWebView *)webViewT {
if ([theWebView respondsToSelector:#selector(scrollView)])
{
UIScrollView *scroll=[theWebView scrollView];
float zoom=theWebView.bounds.size.width/scroll.contentSize.width;
[scroll setZoomScale:zoom animated:NO];
}
}
Any idea? Thanks!
In Some of cases this types of problem Generated. At that time java script use for control of Zoom of UIWebView, use following code.
NSString *jsCommand = [NSString stringWithFormat:#"document.body.style.zoom = 1.5;"];
[webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];
Other way is
Refer this Answer UIWebView does not scale content to fit

how to eliminate the blank frame while flipping over to the next view

i am currently using this(AFKPageFlipper)
to produce the desired flipboard animation in my application
,there are 4 static html pages named 1.html,2..so on
loadView
- (void) loadView {
[super loadView];
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
flipper = [[AFKPageFlipper alloc] initWithFrame:self.view.bounds] ;
flipper.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
NSURLRequest *urlReq=[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:#"1" ofType:#"html"]isDirectory:NO]];
;
//[web loadRequest:urlReq];
NSURLRequest *urlReq1=[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:#"2" ofType:#"html"]isDirectory:NO]];
NSURLRequest *urlReq2=[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:#"3" ofType:#"html"]isDirectory:NO]];
;
NSURLRequest *urlReq3=[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:#"4" ofType:#"html"]isDirectory:NO]];
arr=[[NSArray alloc]initWithObjects:urlReq,urlReq1,urlReq2,urlReq3,nil];
flipper.dataSource = self;
[self.view addSubview:flipper];
}
data source for the AFKFlipper
- (NSInteger) numberOfPagesForPageFlipper:(AFKPageFlipper *)pageFlipper
{
NSLog(#"%i",arr.count);
return [arr count];
}
- (UIView *) viewForPage:(NSInteger) page inFlipper:(AFKPageFlipper *) pageFlipper
{
web= [[UIWebView alloc] initWithFrame:CGRectMake(0, 40, 320, 385)];
[web loadRequest:[arr objectAtIndex:page-1]];
return web;
}
i can flip across multiple webviews,but the problem i am facing is when i am halfway flipping the page i cant see my next view,it seems to be a blank page,it gets loaded after i flip my page completely
In the flipboard you can see the next view partially and previous view partially,what should i do to show my next view when the current view if halfway flipped
I tried AFKPageFlipper,, but i dont think messing with its original code is any solution.
what u can try is, keep ready all the views u r going to provide to AFKPageFlipper.
NSMutableArray *webViewArray;
-(void)viewDidLoad
{
webViewArray=[[NSMutableArray alloc]int];
for(int ii=0;ii<4;ii++)
{
web= [[UIWebView alloc] initWithFrame:CGRectMake(0, 40, 320, 385)];
[web loadRequest:[arr objectAtIndex:ii]];
[webViewArray addObject:web];
web=nil;
}
}
- (UIView *) viewForPage:(NSInteger) page inFlipper:(AFKPageFlipper *) pageFlipper
{
return [webViewArray objectAtIndex:page];
}

iphone app web view not appearing on device

i have a view controller and in view did load method i have this code
- (void)viewDidLoad
{
self.navigationItem.title=#"Twitter Profile";
CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 370.0);
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor whiteColor]];
NSString *urlAddress = #"http://twitter.com/#!/SummerApps";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[self.view addSubview:webView];
[webView release];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
in simulator everything works fine but on device the page just doesn't load.
I also have the same code on another view for facebook and it works fine the link is the only difference! Any help?
have you connected your webView with outlet connection ? or check your internet setting in Simulator.
Well when i open the same link with safari on my i-device pops up an alert that tells me that the certificate is not trusted if i click ok then it loads? Do you know whats going on i think that's why it doesn't load in my built in web view

uiwebview without interface builder

I've to switch a part of my app: I will implement a web view insread of a picture (imageview).
So I tried to make it with the interface builder but there is too many errors so I prefer to use code!
for the pictures, I user those lines :
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
self.imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0,64,320,367);
[self.view addSubview:imageView];
[self.imageView release];
Now, I tried to use this code but nothing's showed:
#property (nonatomic, retain) IBOutlet UIWebView *webView;
...
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.google.fr"]]];
[self.view addSubview:webView];
If you know how to make .... would be nice for me,
THANKS!
Declare in your h file:
UIWebView *contentWebView;
And also tell to your viewController that you will implement <UIWebViewDelegate>
In viewDidLoad Add:
contentWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
contentWebView.delegate = self;
contentWebView.multipleTouchEnabled = YES;
contentWebView.scalesPageToFit = NO;
[self.view addSubview:contentWebView];
In dealloc don't forget to release the webView:
[contentWebView release];
And implement the delegate methods:
#pragma mark -
#pragma mark WebViewDelegates
- (void)webViewDidStartLoad:(UIWebView *)webView{
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
}
And also you need to load an request. You can doit in viewDidLoad after you have added the webView to your view:
[contentWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.apple.com/"]]];
adjust the frame as u needed and if add anything like imageview as subview to webview then u have to use bringsubviewtofront function.
- (void) initUIWebView {
NSLog(#"DetailViewController->initUIWebView {");
UIWebView *aWebView;
// init and create the UIWebView
aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
aWebView.autoresizesSubviews = YES;
aWebView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
//set the web view delegates for the web view to be itself
[aWebView setDelegate:self];
//Set the URL to go to for your UIWebView
NSString *urlAddress = #”http://www.google.com”;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//load the URL into the web view.
[aWebView loadRequest:requestObj];
//add the web view to the content view
[self.view addSubview:aWebView];
[aWebView release], aWebView = nil;
}
- (void)viewDidLoad {
[self initUIWebView]; // <<<<<<<<<<<< this calls the UIWebView Function
[super viewDidLoad];
}

How make webview with Rounded Rectangle corners?

I want my webview with Rounded Rectangle Corners.
Any help ?
Here's how:
//first, you
#import <QuartzCore/QuartzCore.h>
//.....
//In your method, where you add your UIWebView, do:
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(50, 220, 200, 100)];
//The rounded corner part:
webView.layer.cornerRadius = 5;
webView.clipsToBounds = YES;
//Load a web site:
[webView loadRequest: [NSURLRequest requestWithURL:
[NSURL URLWithString:#"http://www.stackoverflow.com/"]]];
//yourView is the UIView's superview, might be the window, or anything you want
[yourView addSubview: webView];
[webView release];
This uses the QuartzCore framework, and it only works on >= OS 3.0
you can add some mask image over your webView. in such way you can change form of the visible part of your webView