【问题标题】:how to use pagecontrol globally?如何全局使用pagecontrol?
【发布时间】:2011-01-03 06:50:57
【问题描述】:

在我的应用程序中,我想在超过 3 个视图中使用 pagecontrol 实例。所以,我想声明,@property 和 @synthesize 应该在 appDelegate 中。请给出一些想法来做到这一点...

谢谢, 马诺

【问题讨论】:

    标签: iphone uipagecontrol


    【解决方案1】:

    我从未使用过 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 2013-02-16
      • 1970-01-01
      • 2018-08-16
      • 2018-09-19
      • 1970-01-01
      • 2014-11-23
      相关资源
      最近更新 更多