UITabBar tugmachasini dasturlashtirilgan holda Xcode tugmachasida bosish

UITabBarController qilish uchun quyidagi kodni ishlatdim:

ichida AppDelegate.h :

    IBOutlet UITabBarController *rootController;
...
    @property (nonatomic, retain) IBOutlet UITabBarController *rootController;

AppDelegate.m ichida

@synthesize rootController;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   //Override point for customization after application launch.
    [self.window addSubview:rootController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

Endi AppDelegate ichida ushbu usulni qanday amalga oshirishni bilishim kerak:

- (void)SwitchToTab:(int)index{
    //go to tabview 1 or 2 ...
    }
2
[rootController setSelectedItem: [rootController.items objectAtIndex: index]] bilan harakat qilib ko'ring; ?
qo'shib qo'ydi muallif Mat, manba

1 javoblar

Buni qilishingiz mumkin:

self.rootController.selectedIndex = 2;//or whatever index you like

yoki bu:

self.rootController.selectedViewController = oneOfTheViewControllersInTheTabController;

Uchun UITabBarController mos yozuvlar sahifasiga qarang. tafsilotlar.

4
qo'shib qo'ydi