今天我會問你是否有方法來調用另一個視圖控制器的方法,而不是初始化它,或者只是如何將該viewController作爲一個全局變量在.h文件中聲明。 請幫助我。 我正在使用PageViewController,我必須使用contentViewController alredy初始化的方法。ViewController訪問數據
這裏創建我ViewControllers:
- (void)createTheContent {
NSLog(@"createTheContent");
pageController = nil;
//[pageController removeFromParentViewController];
//[pageController awakeFromNib];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin] forKey: UIPageViewControllerOptionSpineLocationKey];
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options: options];
pageController.dataSource = self;
[[pageController view] setFrame:CGRectMake(0, 0, 320, 365)];
initialViewController = [self viewControllerAtIndex:0];
NSMutableArray *viewControllers = [NSArray arrayWithObject:initialViewController];
[pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:pageController];
[[self view] addSubview:[pageController view]];
[pageController didMoveToParentViewController:self];
}
這裏是我在.h文件中propertys:
contentViewController *initialViewController;
}
//Page View Controller Properties
@property (strong, nonatomic) UIPageViewController *pageController;
@property (strong, nonatomic) NSArray *pageContent;
@property (strong, nonatomic) NSMutableArray *pageStrings;
@property (strong, nonatomic) id dataObject;
你的'contentViewController'是什麼? – sergio