Ios 如何为Objc使用CAPSPageMenu源代码?

Ios 如何为Objc使用CAPSPageMenu源代码?,ios,objective-c,Ios,Objective C,我正在使用objective C开发IOS项目。 我要做滑动标签页。 我从github找到了这个源代码。 这是我使用CAPSPageMenu的源代码。 什么时候 它只显示白色屏幕。 请帮忙。 谢谢。此错误与PageMenu无关,请注释注册推送通知的代码,然后重试 在按下viewcontroller之前,请检查viewcontroller是否为零 Capspagemenus在我们的项目中运行良好 @interface BusinessTabViewController () @property(

我正在使用objective C开发IOS项目。 我要做滑动标签页。 我从github找到了这个源代码。

这是我使用CAPSPageMenu的源代码。 什么时候

它只显示白色屏幕。 请帮忙。
谢谢。

此错误与PageMenu无关,请注释注册推送通知的代码,然后重试

在按下viewcontroller之前,请检查viewcontroller是否为零

Capspagemenus在我们的项目中运行良好

@interface BusinessTabViewController ()
@property(nonatomic) CAPSPageMenu* pageMenu;
@end

@implementation BusinessTabViewController


-(void) viewDidLayoutSubviews{
    NSMutableArray *controllerArray = [NSMutableArray array];
    UIViewController*controller = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller.title  = @"Sample title1";
    UIViewController*controller1 = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller1.title  = @"Sample title2";
    UIViewController*controller2 = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller2.title  = @"Sample title3";
    [controllerArray addObject:controller];
    [controllerArray addObject:controller1];
    [controllerArray addObject:controller2];

    NSDictionary *parameteres = @{
                                  CAPSPageMenuOptionMenuItemSeparatorWidth:@(4.3),
                                  CAPSPageMenuOptionUseMenuLikeSegmentedControl:@(YES),
                                  CAPSPageMenuOptionMenuItemSeparatorPercentageHeight:@(0.1),
                                  CAPSPageMenuOptionMenuHeight:@(40),
                                  CAPSPageMenuOptionMenuMargin:@(20),
                                  CAPSPageMenuOptionSelectionIndicatorHeight:@(2.0)

                                  };
    _pageMenu = [[CAPSPageMenu alloc] initWithViewControllers:controllerArray frame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) options:parameteres];
    [self.view addSubview:_pageMenu.view];

}
我使用viewDidLayoutSubviews()获得帧的精确大小。
工作正常。

您提到的库看起来不错。超过3k颗星星。检查您的代码,您一定忘了初始化视图控制器。它是正确的。谢谢,谢谢你的回答。你是对的。我编辑了这个问题。请看这个,帮帮我。谢谢。检查控制器是否为零,控制器阵列是否正常。然后尝试更改以下行参数=@{CAPSPageMenuOptionMenuItemWidthBasedOnTitleTextWidth:@(否),CAPSPageMenuOptionMenuHeight:@(44.0)谢谢。这是我的错。我没有导航到正确的uiviewcontroller。再次感谢。使用未声明的标识符“CAPSPageMenuOptionMenuItemSeparatorWidth”-集成最新页面菜单(2.0.0)时出错在我的Objective C项目中。很抱歉,这是我的错误,我使用Pods进行了集成,它采用的是swift版本,所以我只是手动集成了capspagemen.h和capspagemen.m,并且只使用Objective C方法,效果很好:)
@interface BusinessTabViewController ()
@property(nonatomic) CAPSPageMenu* pageMenu;
@end

@implementation BusinessTabViewController


-(void) viewDidLayoutSubviews{
    NSMutableArray *controllerArray = [NSMutableArray array];
    UIViewController*controller = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller.title  = @"Sample title1";
    UIViewController*controller1 = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller1.title  = @"Sample title2";
    UIViewController*controller2 = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller2.title  = @"Sample title3";
    [controllerArray addObject:controller];
    [controllerArray addObject:controller1];
    [controllerArray addObject:controller2];

    NSDictionary *parameteres = @{
                                  CAPSPageMenuOptionMenuItemSeparatorWidth:@(4.3),
                                  CAPSPageMenuOptionUseMenuLikeSegmentedControl:@(YES),
                                  CAPSPageMenuOptionMenuItemSeparatorPercentageHeight:@(0.1),
                                  CAPSPageMenuOptionMenuHeight:@(40),
                                  CAPSPageMenuOptionMenuMargin:@(20),
                                  CAPSPageMenuOptionSelectionIndicatorHeight:@(2.0)

                                  };
    _pageMenu = [[CAPSPageMenu alloc] initWithViewControllers:controllerArray frame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) options:parameteres];
    [self.view addSubview:_pageMenu.view];

}