簡體   English   中英

選項卡欄項目上的選項卡欄控制器情節提要單擊事件

[英]Tab Bar Controller Storyboard click event on tab bar item

我在Storyboard中有一個Tab Bar Controller,與2個視圖相連。 在View 2(TimelineView)中,我在.h文件中進行了設置:

@interface Timeline_Overview : UIViewController<UITabBarDelegate>{
}
@property (nonatomic, retain) IBOutlet UITabBarItem *PostImage;

並在.m文件中:

-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{

NSLog(@"test");
if(item.tag==2)
{

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UITabBarController *TimeLine = [mainStoryboard instantiateViewControllerWithIdentifier:@"Post_Photo_One"];
    [self presentViewController:TimeLine animated:YES completion:nil];
}
else
{
    //your code
}
}

但是這個虛空不會觸發:(

這是情節提要中的圖片: 故事板

有人可以幫忙嗎?

編輯:

這是我的檢查看起來像您的檢查,它不起作用:(

在此處輸入圖片說明

編輯2:

在我的情節提要中,我已將“自定義類”從“發布圖像”選項卡設置為我的“ Timeline_Overview”,但它不起作用:( 在此處輸入圖片說明

storyboard UITabBarController中的UITabBarController delegate的連接檢查器的委托更改為您的相關類,請參見屏幕截圖:

在此處輸入圖片說明

並且不要忘記將身份檢查器更改為自定義標簽欄:

在此處輸入圖片說明

如果您使用情節提要,請執行此操作

在didFinishLaunchingWithOptions中

UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;
[tabBar setDelegate:self];

同樣在AppDelegate中,保留<UITabBarControllerDelegate>

接着

-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
   //Write your code here
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM