ページ間を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
rootviewcontroller で:
#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;
}
この問題を解決するにはどうすればよいですか? また、Web ビューのズームを無効にする方法を教えてください。よろしくお願いします。