小编Kyl*_*yle的帖子

UIPageViewController,如何正确跳转到特定页面而不会弄乱数据源指定的顺序?

我发现了一些关于如何UIPageViewController跳转到特定页面的问题,但我注意到跳跃的一个额外问题,没有任何答案似乎承认.

没有进入我的iOS应用程序的细节(类似于分页日历),这是我正在经历的.我声明了一个UIPageViewController,设置当前的视图控制器,并实现一个数据源.

// end of the init method
        pageViewController = [[UIPageViewController alloc] 
        initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
          navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                        options:nil];
        pageViewController.dataSource = self;
        [self jumpToDay:0];
}

//...

- (void)jumpToDay:(NSInteger)day {
        UIViewController *controller = [self dequeuePreviousDayViewControllerWithDaysBack:day];
        [pageViewController setViewControllers:@[controller]
                                    direction:UIPageViewControllerNavigationDirectionForward
                                     animated:YES
                                   completion:nil];
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
        NSInteger days = ((THDayViewController *)viewController).daysAgo;
        return [self dequeuePreviousDayViewControllerWithDaysBack:days + 1];
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
        NSInteger days = ((THDayViewController *)viewController).daysAgo;
        return [self dequeuePreviousDayViewControllerWithDaysBack:days - 1];
}

- (UIViewController *)dequeuePreviousDayViewControllerWithDaysBack:(NSInteger)days { …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uipageviewcontroller

62
推荐指数
4
解决办法
5万
查看次数

为什么具有已定义prop的对象类型不是具有Flow中可选prop的对象类型的子类型?

在Flow中,我可以声明一个带有可选prop的对象类型,以便定义了该prop的对象满足它.

function getName(thing: {name?: string}): string {
  return thing.name || 'unknown';
}
getName({name: 'bob'}); // works
Run Code Online (Sandbox Code Playgroud)

但是如果我在传递它之前声明了param的对象类型,Flow会记录一个错误.

const thing: {name: string} = {name: 'bob'};
getName(thing); // error
Run Code Online (Sandbox Code Playgroud)

那么为什么具有定义道具的类型不满足具有与可选项相同的道具的类型?我将如何修复这些注释?

javascript flowtype

4
推荐指数
1
解决办法
107
查看次数