메소드에 - (void)setViewControllers:(NSArray *)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL finished))completion
이 설정되어 있습니다. 메서드가 호출 될 때마다 다음 페이지로 이동하지 않습니다. 대신 UIPageViewController 스토리 보드로 이동 한 다음 충돌합니다. 내가 뭘 잘못하고 있는지 모르겠다. 나는 pageviewcontroller에 대해 MSPageViewController을 사용하고 있습니까?UIPageViewController setViewController로 인해 앱이 다운 됨
Heres는 내 코드 :
UIViewController *viewcont = [[UIViewController alloc]init];
NSArray *viewControllers = [NSArray arrayWithObject:viewcont];
[self setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
감사합니다.
pageIndex 속성이 합성 된 MSPageViewControllerChild를 모두 준수하는 스토리 보드가 3 개 있습니다. IntroPageViewController는 첫 번째 스토리 보드 (p1)입니다.
PagingViewController.h : 당신이 MSPageViewControllerChild
을 준수하지 않는 컨트롤러, MSPageViewController
을 사용하고 같은
//
// PagingViewController.m
// MordechaiLevi
//
// Created by Mordechai Levi on 4/10/14.
// Copyright (c) 2014 Mordechai Levi. All rights reserved.
//
#import "PagingViewController.h"
#import "IntroPageViewController.h"
#import "MSPageViewController.h"
@interface PagingViewController()
@end
@implementation PagingViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.device = [UIDevice currentDevice];
self.device.proximityMonitoringEnabled = YES;
if (self.device.proximityMonitoringEnabled == YES) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sensorCovered) name:@"UIDeviceProximityStateDidChangeNotification" object:nil];
}else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Uh Oh!" message:@"To use this app you need a device with a proximity sensor." delegate:self cancelButtonTitle:@"Got it" otherButtonTitles:nil, nil];
[alert show];
}
self.view.backgroundColor = [UIColor colorWithRed:0.2 green:0.859 blue:0.643 alpha:1.0];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)sensorCovered {
if (self.device.proximityState == YES) {
IntroPageViewController *viewcont = [[IntroPageViewController alloc]init];
NSArray *viewControllers = [NSArray arrayWithObject:viewcont];
[self setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
NSLog(@"sensor covered");
}else{
NSLog(@"sensor not covered");
}
}
- (NSArray *)pageIdentifiers {
return @[@"p1", @"p2", @"p3"];
}
@end
오류 로그를 추가 할 수 있습니까? – shannoga
@shannoga가 방금 질문에 추가했습니다. – user3186310
예외 중단 점을 추가하고 충돌이 발생한 위치를 확인하십시오. –