Permalink
Browse files

first import

  • Loading branch information...
1 parent 7a05b64 commit 9815bcca3f67ffb0edb625110cfa01b04477c3f1 Prince committed Sep 11, 2012
Showing with 1,320 additions and 0 deletions.
  1. +394 −0 PSTableViewSample/PSTableViewSample.xcodeproj/project.pbxproj
  2. +19 −0 PSTableViewSample/PSTableViewSample/AppDelegate.h
  3. +64 −0 PSTableViewSample/PSTableViewSample/AppDelegate.m
  4. +13 −0 PSTableViewSample/PSTableViewSample/CellModel.h
  5. +13 −0 PSTableViewSample/PSTableViewSample/CellModel.m
  6. +13 −0 PSTableViewSample/PSTableViewSample/CustomStyleViewController.h
  7. +73 −0 PSTableViewSample/PSTableViewSample/CustomStyleViewController.m
  8. +13 −0 PSTableViewSample/PSTableViewSample/CustomTableCell1.h
  9. +64 −0 PSTableViewSample/PSTableViewSample/CustomTableCell1.m
  10. +38 −0 PSTableViewSample/PSTableViewSample/PSTableViewSample-Info.plist
  11. +14 −0 PSTableViewSample/PSTableViewSample/PSTableViewSample-Prefix.pch
  12. +13 −0 PSTableViewSample/PSTableViewSample/TableCell.h
  13. +24 −0 PSTableViewSample/PSTableViewSample/TableCell.m
  14. +14 −0 PSTableViewSample/PSTableViewSample/ViewController.h
  15. +54 −0 PSTableViewSample/PSTableViewSample/ViewController.m
  16. +2 −0 PSTableViewSample/PSTableViewSample/en.lproj/InfoPlist.strings
  17. +119 −0 PSTableViewSample/PSTableViewSample/en.lproj/ViewController.xib
  18. +18 −0 PSTableViewSample/PSTableViewSample/main.m
  19. +25 −0 src/Model/PSBaseTableCellModel.h
  20. +23 −0 src/Model/PSBaseTableCellModel.m
  21. +19 −0 src/Model/PSBaseTableListModel.h
  22. +27 −0 src/Model/PSBaseTableListModel.m
  23. +16 −0 src/PSBaseTableCell.h
  24. +41 −0 src/PSBaseTableCell.m
  25. +39 −0 src/PSBaseTableViewController.h
  26. +153 −0 src/PSBaseTableViewController.m
  27. +15 −0 src/PSBaseTableViewDataModelProtocol.h

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,19 @@
+//
+// AppDelegate.h
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class ViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) ViewController *viewController;
+
+@end
@@ -0,0 +1,64 @@
+//
+// AppDelegate.m
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+#import "ViewController.h"
+#import "CustomStyleViewController.h"
+
+@implementation AppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ // Override point for customization after application launch.
+ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
+
+ // Override point for customization after application launch.
+ UIViewController *viewController1 = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
+ viewController1.title = @"Build-in Style";
+
+ UIViewController *viewController2 = [[CustomStyleViewController alloc] init];
+ viewController2.title = @"Custom Style";
+
+ UITabBarController *tabBarController = [[UITabBarController alloc] init];
+ tabBarController.viewControllers = @[viewController1, viewController2];
+ self.window.rootViewController = tabBarController;
+
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
@@ -0,0 +1,13 @@
+//
+// CellModel.h
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "PSBaseTableCellModel.h"
+
+@interface CellModel : PSBaseTableCellModel
+
+@end
@@ -0,0 +1,13 @@
+//
+// CellModel.m
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "CellModel.h"
+
+@implementation CellModel
+
+@end
@@ -0,0 +1,13 @@
+//
+// FirstTableViewController.h
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "PSBaseTableViewController.h"
+
+@interface CustomStyleViewController : PSBaseTableViewController
+
+@end
@@ -0,0 +1,73 @@
+//
+// FirstTableViewController.m
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "CustomStyleViewController.h"
+#import "CellModel.h"
+
+@interface CustomStyleViewController ()
+
+@end
+
+@implementation CustomStyleViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self) {
+ // Custom initialization
+ }
+ return self;
+}
+
+- (void)prepareData {
+ self.dataArray = nil;
+ self.dataArray = [NSMutableArray array];
+
+ PSBaseTableListModel *sectionList = [[PSBaseTableListModel alloc] init];
+ sectionList.cellClassName = @"CustomTableCell1";
+
+ for (int i = 0; i < 10; i++) {
+ CellModel *model = [[CellModel alloc] init];
+ model.title = [NSString stringWithFormat:@"Custom Style #%i",i];
+ model.description = [NSString stringWithFormat:@"Custom Style Description #%i",i];
+ [sectionList.cellModels addObject:model];
+ }
+
+ [self.dataArray addObject:sectionList];
+ [self refreshTableView];
+}
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view.
+
+ self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
+ [self prepareData];
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+#pragma mark - UITableView
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+ return 80;
+}
+
+
+#pragma mark - UITableViewDataSource
+@end
@@ -0,0 +1,13 @@
+//
+// CustomTableCell1.h
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "PSBaseTableCell.h"
+
+@interface CustomTableCell1 : PSBaseTableCell
+
+@end
@@ -0,0 +1,64 @@
+//
+// CustomTableCell1.m
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "CustomTableCell1.h"
+#import "CellModel.h"
+
+@interface CustomTableCell1 () {
+ UILabel *_titleLabel;
+ UILabel *_descriptionLabel;
+}
+
+@end
+
+@implementation CustomTableCell1
+
+-(void)prepareControl {
+ self.backgroundColor = [UIColor lightGrayColor];
+ self.selectionStyle = UITableViewCellSelectionStyleGray;
+
+ _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 17, 300, 20)];
+ [_titleLabel setBackgroundColor:[UIColor clearColor]];
+ [_titleLabel setFont:[UIFont systemFontOfSize:14.0f]];
+ [_titleLabel setTextColor:[UIColor colorWithRed:26/255 green:26/255 blue:26/255 alpha:1.0f ]];
+ [_titleLabel setShadowColor:[UIColor whiteColor]];
+ [_titleLabel setShadowOffset:CGSizeMake(1, 1)];
+
+ _descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 38, 300, 20)];
+ [_descriptionLabel setBackgroundColor:[UIColor clearColor]];
+ [_descriptionLabel setFont:[UIFont systemFontOfSize:10.0f]];
+ [_descriptionLabel setTextColor:[UIColor colorWithRed:112/255 green:112/255 blue:112/255 alpha:1.0f ]];
+ [_descriptionLabel setShadowColor:[UIColor whiteColor]];
+ [_descriptionLabel setShadowOffset:CGSizeMake(1, 1)];
+
+ [self addSubview:_titleLabel];
+ [self addSubview:_descriptionLabel];
+}
+
+- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
+{
+ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+ if (self) {
+ // Initialization code
+ [self prepareControl];
+ }
+ return self;
+}
+
+- (void)setContent:(id)data {
+ if (![data isKindOfClass:[CellModel class]]) {
+ return ;
+ }
+
+ CellModel *model = (CellModel *)data;
+
+ [_titleLabel setText:model.title];
+ [_descriptionLabel setText:model.description];
+}
+
+@end
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.prince.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'PSTableViewSample' target in the 'PSTableViewSample' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_4_0
+#warning "This project uses features only available in iOS SDK 4.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
@@ -0,0 +1,13 @@
+//
+// TableCell.h
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "PSBaseTableCell.h"
+
+@interface TableCell : PSBaseTableCell
+
+@end
@@ -0,0 +1,24 @@
+//
+// TableCell.m
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import "TableCell.h"
+#import "CellModel.h"
+
+@implementation TableCell
+
+- (void)setContent:(id)data {
+ if (![data isKindOfClass:[CellModel class]]) {
+ return ;
+ }
+
+ CellModel *model = (CellModel *)data;
+
+ [self.textLabel setText:model.title];
+}
+
+@end
@@ -0,0 +1,14 @@
+//
+// ViewController.h
+// PSTableViewSample
+//
+// Created by Prince on 12/9/11.
+// Copyright (c) 2012年 Prince. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "PSBaseTableViewController.h"
+
+@interface ViewController : PSBaseTableViewController
+
+@end
Oops, something went wrong.

0 comments on commit 9815bcc

Please sign in to comment.