タップされたボタンがタップされたときに別のビューからRootViewに移動する

StackOverflow https://stackoverflow.com//questions/25085564

質問

このコードを使用して、タブ(RootView)をプログラムで変更することを使用しています。

NSInteger tabitem = tabBarController.selectedIndex;
[[tabBarController.viewControllers objectAtIndex:tabitem] popToRootViewControllerAnimated:YES];
.

しかし、ビューからタブを変更するためのボタンを使用したい場合は、RootViewを表示できません。私はこのコードを使っていますが、RootView:

は表示されません
self.tabBarController.selectedIndex = 3;
.

役に立ちましたか?

解決

これは解決策です:

https://stackoverflow.com/a/12681125/3507283

int index = 3;
self.tabBarController.selectedIndex = index;
[self.tabBarController.viewControllers[index] popToRootViewControllerAnimated:NO];
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top