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
}

在您的一种观点中:

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