Development‎ > ‎iOS‎ > ‎

LYKits

This page may not be updated for some time - need to write codes first, then documentation. The code snippets page will be updated because that helps my daily work.

*Due to some historical reasons it's named MQPublic (MQ = MacQool), while MQ will be replaced by LY later eventually, when I'm doing a huge refactoring job for the whole structure of all my codes, which may happen when the time is right.

MQAppDelegate & MQAppController

The purpose of these classes are separate functions from an iOS application, which means the functions can be easily moved to another (UINavigationController based) application.

In header file, create a class from MQAppController with some properties and IBOutlets:

  2 #import "MQPublic.h"
  3 
  4 @interface AppPhotoFrame: MQAppController
  5 {
  6     IBOutlet UILabel*           label;
  7     IBOutlet UINavigationItem*  navigationItem;
  8     MQ3DImageView*      image_3d;
  9 }
 10 - (void)load;
 11 @end
 12 
 13 @interface photoframeAppDelegate : MQAppDelegate <UIApplicationDelegate>
 14 {
 15     UIWindow*       window;
 16     AppPhotoFrame*  app;
...

In the implementation file, add most logic in the MQAppController class. Prepare an XIB file if needed:

  3 @implementation AppPhotoFrame
  4 
  5 - (void)load
  6 {
  7     label.text = @"loaded";
  8     image_3d = [[MQ3DImageView alloc] initWithFrame:CGRectMake(10, 50, 300, 300)];
  9     [image_3d set_image:[@"test.png" filename_bundle]];
 10     [image_3d set_color:[UIColor colorWithWhite:0.4 alpha:1]];
 11     [image_3d set_mode:1];
 12     [self.view addSubview:image_3d];
 13 }
 14 
 15 @end

Use the following codesnip in your app delegate, hopefully that should be the only thing needed:

 18 @implementation photoframeAppDelegate
 19 
 20 @synthesize window;
 21 
 22 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 23 {
 24     app = [[AppPhotoFrame alloc] initWithApp:self nib:@"AppPhotoFrame"];
 25 
 26     [self app_init];
 27     [self app_load:app with:@"load"];
 28     
 29     [window addSubview:self.nav.view];
 30     [self.window makeKeyAndVisible];
...

Comments