当我在我contentviewcontroller
的应用程序崩溃的页面之间滑动时,我在我的 .
下面是我的代码:
contentviewcontroller.m
#import "ContentViewController.h"
@interface ContentViewController ()
@end
@implementation ContentViewController
@synthesize m_CtrlWebview,DocumentPath;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
m_CtrlWebview.scrollView.pagingEnabled=YES;
m_CtrlWebview.scrollView.bounces=NO;
m_CtrlWebview.scalesPageToFit=YES;
m_CtrlWebview.backgroundColor=[UIColor clearColor];
//m_CtrlWebview.scrollView.zooming=NO;
m_CtrlWebview.scrollView.zoomScale=1.0;
NSURL *url = [NSURL fileURLWithPath:DocumentPath isDirectory:NO];
[m_CtrlWebview loadRequest:[NSURLRequest requestWithURL:url]];
}
-(void)dealloc
{
[super dealloc];
}
- (void)viewDidUnload
{
//[m_CtrlWebview stopLoading];
[m_CtrlWebview release];
[super viewDidUnload];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
在根视图控制器中:
#pragma mark - UIPageViewControllerDataSource Methods
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController DocumentPath]];
if(currentIndex == 0)
{
return nil;
}
ContentViewController *firstViewController = [self viewControllerAtIndex:currentIndex - 1];
// ContentViewController *secondViewController = [self viewControllerAtIndex:x+1 ];
return firstViewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController DocumentPath]];
if(currentIndex == self.modelArray.count-1)
{
return nil;
}
NSString *Path=[self.modelArray objectAtIndex:currentIndex + 1];
if (![[NSFileManager defaultManager] fileExistsAtPath:Path])
{
return nil;
}
else
{
ContentViewController *firstViewController = [self viewControllerAtIndex:currentIndex + 1];
return firstViewController;
}
}
- (ContentViewController *)viewControllerAtIndex:(NSUInteger)index {
if (([self.modelArray count] == 0) || (index >= [self.modelArray count])) {
return nil;
}
ContentViewController *dataViewController;
dataViewController = [[ContentViewController alloc]initWithNibName:@"ContentViewController" bundle:nil];
dataViewController.DocumentPath = [self.modelArray objectAtIndex:index];
return dataViewController;
}
我该如何解决这个问题?另外如何禁用网页视图的缩放?任何帮助,在此先感谢。