要做到這個分為兩步
第一步, 導入app
#import "AppDelegate.h"
第二步, 監聽方法中先寫加入以下代碼:
[self dismissViewControllerAnimated:YES completion:^{
// 這是從一個模態出來的頁面跳到tabbar的某一個頁面
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UITabBarController *tabViewController = (UITabBarController *) appDelegate.window.rootViewController;
[tabViewController setSelectedIndex:2];
}];
這樣, 就實現了想要的效果.