-(void)Save{
MainScreenContoller *main= [[MainScreenContoller alloc] initWithNibName:@"MainScreenContoller" bundle:nil];
[sel开发者_开发问答f.view.superview addSubview:[main view]];
}
This is the place that i am going to click and my button calls save function.After this i want the application automatically turn to main screen which is the first tab bar this one is the third.
So i click the button and the application switches to the first tab bar.
if you want to select the first tab on the tab bar controller, you can simply do this:
- (void) save
{
// do your saving here
// ...
self.tabBarController.selectedIndex = 0;
}
Try setting this property of UITabBarController
:
@property(nonatomic) NSUInteger selectedIndex
So for the first tab, something like:
self.tabBarController.selectedIndex = 0;
From the documentation:
Setting this property changes the selected view controller to the one at the designated index in the viewControllers array. To select the More navigation controller itself, you must change the value of the selectedViewController property instead.
精彩评论