0

私のアプリケーションでは、3つ以上のビューでpagecontrolのインスタンスを使用したいので、宣言したいのですが、@propertyと@synthesizeはappDelegateにある必要があります。これを行うためのアイデアをいくつか教えてください...

ありがとう、真野

4

1 に答える 1

0

私は pagecontrol を使用したことはありませんが、原則として、コードは次のようになります。

YourAppDelegate .h で

@interface YourAppDelegate : NSObject <UIApplicationDelegate> {
    ...
    UIPageControl *pageControl;
    ...
}

@property (nonatomic, retain) IBOutlet ScrollingViewController *viewController;

YourAppDelegate.m:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    pageControl = [[UIPageControl alloc] init]; // or whatever is needed to set up pagecontrol
}

あなたのビューの1つで:

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
//and then access the variable by appDelegate.variable
于 2011-01-03T08:44:02.860 に答える