Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 第一次加载视图时,UIpageviwcontroller在横向模式下仅加载单个视图_Iphone_Objective C_Ipad_Ios5 - Fatal编程技术网

Iphone 第一次加载视图时,UIpageviwcontroller在横向模式下仅加载单个视图

Iphone 第一次加载视图时,UIpageviwcontroller在横向模式下仅加载单个视图,iphone,objective-c,ipad,ios5,Iphone,Objective C,Ipad,Ios5,我需要有关UIpageviewcontroller的通用应用程序帮助。我将此功能添加到我的应用程序中,它工作正常,但当我第一次以横向模式加载UIpageviewcontroller时,它只显示单个视图。我的问题是,若设备处于横向模式,它第一次只加载单个视图。我想这是因为UIpageviewcontroller的声明代码 代码-: self.Pagecontrol = [[UIPageViewController alloc] initWithTransitionStyle:style navi

我需要有关
UIpageviewcontroller
的通用应用程序帮助。我将此功能添加到我的应用程序中,它工作正常,但当我第一次以横向模式加载
UIpageviewcontroller
时,它只显示单个视图。我的问题是,若设备处于横向模式,它第一次只加载单个视图。我想这是因为
UIpageviewcontroller
的声明代码

代码-:

self.Pagecontrol = [[UIPageViewController alloc] initWithTransitionStyle:style
 navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];



    self.Pagecontrol.delegate = self;

    self.Pagecontrol.dataSource = self;


    //Step 3:
    //Set the initial view controllers.

    PageCurlView *contentViewController = [[PageCurlView alloc] init];

       NSArray *viewControllers = [NSArray arrayWithObject:contentViewController];
    // &&& i add single view controller at time of declaration.   

    CGRect pageViewRect = CGRectMake(self.view.frame.origin.x+15, self.view.frame.origin.y+15, self.view.frame.size.width-45, self.view.frame.size.height-35);
    pageViewRect = CGRectInset(pageViewRect, 5.0, 20.0);
    self.Pagecontrol.view.frame = pageViewRect;


    [self.Pagecontrol setViewControllers:viewControllers
                               direction:UIPageViewControllerNavigationDirectionForward
                                animated:NO
                              completion:nil];


    //Step 4:
    //ViewController containment steps
    //Add the pageViewController as the childViewController
    [self addChildViewController:self.Pagecontrol];

    //Add the view of the pageViewController to the current view


    [self.BaseScrollView addSubview:self.Pagecontrol.view];
    [self.view addSubview:self.BaseScrollView];

    [self.Pagecontrol.view bringSubviewToFront:self.BaseScrollView];


    [self.Pagecontrol didMoveToParentViewController:self];

    //Step 5:
    // set the pageViewController's frame as an inset rect.


    //Step 6:
    //Assign the gestureRecognizers property of our pageViewController to our view's gestureRecognizers property.

 self.Pagecontrol.view.gestureRecognizers = self.Pagecontrol.gestureRecognizers;
//谁能帮我解决这个问题


我感谢你事先的帮助

PVCViewController.h

#import <UIKit/UIKit.h>
#import "ContentViewController.h"


@interface PVCViewController : UIViewController<UIPageViewControllerDataSource>
{
    UIPageViewController *pageController;
    NSArray *pageContent;

}
@property (strong, nonatomic) UIPageViewController *pageController;
@property (strong, nonatomic) NSArray *pageContent;

@end
#import <UIKit/UIKit.h>

@interface ContentViewController : UIViewController
{
    UIPageViewController *pageController;
    NSArray *pageContent;
}
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) id dataObject;
@end
将WebView添加到contentViewController xib,并将outlet连接到contentViewController.h文件中的WebView

就这样

这是输出


但当我调用此行获取当前索引时,它给出了空数组错误,我不知道数组为何为空-:[[self.Pagecontrol viewControllers]objectAtIndex:0];如果我设置了单控制器,它在您的代码中运行良好,我将在这一行遇到错误,即整数索引=[self indexOfViewController:(contentViewController*)viewController];在这一行中,我得到了viewcontrollerwait的空数组。几分钟后,我将给出一个示例
#import <UIKit/UIKit.h>

@interface ContentViewController : UIViewController
{
    UIPageViewController *pageController;
    NSArray *pageContent;
}
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) id dataObject;
@end
#import "ContentViewController.h"

@interface ContentViewController ()

@end

@implementation ContentViewController
@synthesize webView, dataObject;

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [webView loadHTMLString:dataObject
                    baseURL:[NSURL URLWithString:@""]];
}

- (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.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end