0

いくつかの UITabBarController プロパティを持つ RootViewController があります。

@interface RootViewController : UIViewController<LoginViewDelegate, UITabBarControllerDelegate> {
    UIBarButtonItem*    loginButton;
    NSUserDefaults*     prefs;
    UITabBarController* arTabBarController;
    UITabBarController* stvTabBarController;
    UITabBarController* stTabBarController;
    BOOL                tabBarSaved;
}

@property(nonatomic,retain) UIBarButtonItem*    loginButton;
@property(nonatomic,retain) UITabBarController* arTabBarController;
@property(nonatomic,retain) UITabBarController* stvTabBarController;
@property(nonatomic,retain) UITabBarController* stTabBarController;
@property(assign)           BOOL                tabBarSaved;

これらのタブバーコントローラーに別のクラスからアクセスできるようにしたいと考えています。

別のクラスで UIApplication を使用して UITabBarControllers にアクセスし、タブを切り替えるにはどうすればよいですか?

4

2 に答える 2

0

実装で使用する場合@synthesize、実装しているのは getter と setter のパブリック セットです。

つまり、ここで RootViewController へのポインターを取得できれば、その.arTabBarControllerプロパティに対して必要なことを行うこともできます。

于 2010-06-18T18:15:29.133 に答える
0

「keyPaths」も使用できます。何かのようなもの:

UITabBarController *controller = [[UIApplication sharedApplication] valueForKeyPath:@"delegate.rootViewController.arTabController"];

Key-Value コーディング プログラミング ガイドを参照してください。

于 2010-06-18T20:45:41.680 に答える