2017-05-19 4 views
0

私は目標Cを使ってIOSプロジェクトを開発中です。 私はスライドタブページを作ろうとしています。 githubからこのソースが見つかりました。 ObjcにCAPSPageMenu sourceを使用するには?

これは私がCAPSPageMenuを使用するソースコードです。 の場合

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

@implementation BusinessTabViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSMutableArray *controllerArray = [NSMutableArray array]; 
    UIViewController*controller = [[UIViewController alloc] initWithNibName:@"GongsiyingyeViewController" bundle:nil]; 
    controller.title = @"Sample title"; 
    [controllerArray addObject:controller]; 
    NSDictionary *parameteres = @{CAPSPageMenuOptionMenuItemSeparatorWidth:@(4.3), CAPSPageMenuOptionUseMenuLikeSegmentedControl:@(YES), CAPSPageMenuOptionMenuItemSeparatorPercentageHeight:@(0.1)}; 
    _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]; 
} 

白い画面のみを表示します。 助けてください。おかげさまで

+1

あなたが言及したライブラリはよく見えます。 3k個以上の星。コードを確認するには、View Controllerを初期化するのを忘れていなければなりません。 – iSaalis

+0

そうだった。ありがとう。 – fastworker399

答えて

0
@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()を使って正確なフレームサイズを取得しています。 正常に動作しています。

+0

は今すぐうまく動作します:-) –

0

エラーはPageMenuとは関係ありません。プッシュ通知を登録するコードをコメントしてから試してみてください。

そして、viewcontrollerをプッシュする前に、そのviewcontrollerがnilかどうかをチェックしてください。

私たちのプロジェクトでは、CAPSPageMenuがうまく機能しています。

+0

お返事ありがとうございます。あなたが正しいです。 私はこの質問を編集しました。 これを参照してください。おかげさまで – fastworker399

+0

コントローラがゼロでないことを確認し、そのcontrollerArrayを追加しています。次の行パラメータを変更してみてください。= @ {CAPSPageMenuOptionMenuItemWidthBasedOnTitleTextWidth:@(NO)、CAPSPageMenuOptionMenuHeight:@(44.0) –

+0

ありがとうございます。私の責任です。私は正しいuiviewcontrollerに移動しませんでした。 もう一度ありがとうございます。 – fastworker399

関連する問題