01-QQ 3-最终重构版 Demo示例程序源代码
- 源代码下载链接:01-QQ 3.zip
292.5 KB -
// QQAppDelegate.h
Map - //
- // QQAppDelegate.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQAppDelegate : UIResponder <UIApplicationDelegate>
- @property(strong,nonatomic) UIWindow *window;
- @end
-
// QQAppDelegate.m
Map - //
- // QQAppDelegate.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQAppDelegate.h"
- #import"QQMainViewController.h"
- @implementationQQAppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- QQMainViewController *main = [[QQMainViewController alloc] init];
- self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:main];
- // NSLog(@"%@", self.window.rootViewController);
- [self.window makeKeyAndVisible];
- returnYES;
- }
- - (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
-
// QQDock.h
Map - //
- // QQDock.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @classQQDock;
- @protocolQQDockDelegate <NSObject>
- @optional
- - (void)dock:(QQDock *)dock didSelectedFromIndex:(int)from toIndex:(int)to;
- @end
- @interfaceQQDock : UIView
- #pragma mark添加一个Dock上的小按钮
- - (void)addDockItem:(NSString *)title icon:(NSString *)icon selectedIcon:(NSString *)selectedIcon;
- @property(nonatomic,weak)id<QQDockDelegate> delegate;
- @end
-
// QQDock.m
Map - //
- // QQDock.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQDock.h"
- #import"QQDockItem.h"
- @interfaceQQDock()
- {
- QQDockItem *_selectedItem;
- }
- @end
- @implementationQQDock
- - (id)initWithFrame:(CGRect)frame
- {
- self= [superinitWithFrame:frame];
- if(self) {
- // Initialization code
- }
- returnself;
- }
- #pragma mark添加一个Dock上的小按钮
- - (void)addDockItem:(NSString *)title icon:(NSString *)icon selectedIcon:(NSString *)selectedIcon
- {
- QQDockItem *item = [QQDockItem buttonWithType:UIButtonTypeCustom];
- //按钮的图标
- [item setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
- [item setImage:[UIImage imageNamed:selectedIcon] forState:UIControlStateSelected];
- //按钮的文字
- [item setTitle:title forState:UIControlStateNormal];
- //监听按钮的点击(UIControlEventTouchDown一按下去就会触发点击事件)
- [item addTarget:selfaction:@selector(itemClick:) forControlEvents:UIControlEventTouchDown];
- [selfaddSubview:item];
- //取出所有的按钮,排列frame
- [selfadjustItemFrames];
- }
- - (void)adjustItemFrames
- {
- intcount =self.subviews.count;
- CGFloat itemW =self.frame.size.width / count;
- CGFloat itemH =self.frame.size.height;
- CGFloat itemY =0;
- for(inti =0; i<count; i++) {
- CGFloat itemX = i * itemW;
- QQDockItem *child =self.subviews[i];
- child.frame = CGRectMake(itemX, itemY, itemW, itemH);
- //绑定tag
- child.tag = i;
- //按钮被选中时的背景图片
- NSString *selectedBg =nil;
- if(i ==0) {//最左边
- selectedBg =@"tabbar_sel_left.png";
- //默认选中最左边的按钮(相当于点击了这个按钮)
- [selfitemClick:child];
- }elseif(i == count -1) {//最右边
- selectedBg =@"tabbar_sel_right.png";
- }else{//中间
- selectedBg =@"tabbar_sel_middle.png";
- }
- [child setBackgroundImage:[UIImage imageNamed:selectedBg] forState:UIControlStateSelected];
- }
- }
- - (void)itemClick:(QQDockItem *)item
- {
- // 0.通知代理
- if([_delegate respondsToSelector:@selector(dock:didSelectedFromIndex:toIndex:)])
- {
- [_delegate dock:selfdidSelectedFromIndex:_selectedItem.tag toIndex:item.tag];
- }
- // 1.取消选中当前选中的按钮
- _selectedItem.selected =NO;
- // 2.选中新点击的按钮
- item.selected =YES;
- // 3.让新点击的按钮成为当前选中的按钮
- _selectedItem = item;
- }
- @end
-
// QQDockItem.h
Map - //
- // QQDockItem.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQDockItem : UIButton
- @end
-
// QQDockItem.m
Map - //
- // QQDockItem.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQDockItem.h"
- #define kImageScale0.6
- @implementationQQDockItem
- #pragma mark init方法内部默认会调用initWithFrame:
- - (id)initWithFrame:(CGRect)frame
- {
- self= [superinitWithFrame:frame];
- if(self) {
- //里面的图片居中
- self.imageView.contentMode = UIViewContentModeCenter;
- //里面的文字居中
- self.titleLabel.textAlignment = NSTextAlignmentCenter;
- //文字字体
- self.titleLabel.font = [UIFont systemFontOfSize:12];
- }
- returnself;
- }
- #pragma mark当按钮达到高亮状态的时候会调用,并且默认会在这个方法中进行高亮处理
- - (void)setHighlighted:(BOOL)highlighted { }
- #pragma mark设置内部imageView的frame
- - (CGRect)imageRectForContentRect:(CGRect)contentRect
- {
- CGFloat imgW = contentRect.size.width;
- CGFloat imgH = contentRect.size.height * kImageScale;
- returnCGRectMake(0,0, imgW, imgH);
- }
- #pragma mark设置内部titleLabel的frame
- - (CGRect)titleRectForContentRect:(CGRect)contentRect
- {
- CGFloat titleW = contentRect.size.width;
- CGFloat titleY = contentRect.size.height * kImageScale;
- CGFloat titleH = contentRect.size.height - titleY;
- returnCGRectMake(0, titleY, titleW, titleH);
- }
- @end
-
// QQFriendsViewController.h
Map - //
- // QQFriendsViewController.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQFriendsViewController : UITableViewController
- @end
-
// QQFriendsViewController.m
Map - //
- // QQFriendsViewController.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQFriendsViewController.h"
- @interfaceQQFriendsViewController ()
- @end
- @implementationQQFriendsViewController
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- self.view.backgroundColor = [UIColor blueColor];
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"添加"style:UIBarButtonItemStyleBordered target:nilaction:nil];
- UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"分组",@"全部"]];
- segment.segmentedControlStyle = UISegmentedControlStyleBar;
- segment.selectedSegmentIndex =0;
- self.navigationItem.titleView = segment;
- }
- - (void)didReceiveMemoryWarning
- {
- [superdidReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- #warning Potentially incomplete method implementation.
- // Return the number of sections.
- return0;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- #warning Incomplete method implementation.
- // Return the number of rows in the section.
- return0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- staticNSString *CellIdentifier =@"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // Configure the cell...
- returncell;
- }
- /*
- // Override to support conditional editing of the table view.
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the specified item to be editable.
- return YES;
- }
- */
- /*
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
- */
- /*
- // Override to support rearranging the table view.
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
- {
- }
- */
- /*
- // Override to support conditional rearranging of the table view.
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the item to be re-orderable.
- return YES;
- }
- */
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];
- */
- }
- @end
-
// QQMainViewController.h
Map - //
- // QQMainViewController.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQMainViewController : UIViewController
- @end
-
// QQMainViewController.m
Map - //
- // QQMainViewController.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQMainViewController.h"
- #import"QQFriendsViewController.h"
- #import"QQMessageViewController.h"
- #import"QQSettingViewController.h"
- #import"QQWorldViewController.h"
- #import"UIImage+QQ.h"
- #import"UINavigationItem+QQ.h"
- #import"QQDock.h"
- @interfaceQQMainViewController () <QQDockDelegate>
- {
- QQDock *_dock;
- // NSArray *_allViewControllers; //所有需要显示的控制器
- }
- @end
- @implementationQQMainViewController
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- // 0.创建所有的小控制器
- QQMessageViewController *msg = [[QQMessageViewController alloc] init];
- QQFriendsViewController *friends = [[QQFriendsViewController alloc] init];
- QQWorldViewController *world = [[QQWorldViewController alloc] init];
- QQSettingViewController *setting = [[QQSettingViewController alloc] init];
- //当两个控制器互为父子关系的时候,它们的view一般也是互为父子关系
- // self.childViewControllers
- //通过addChildViewController方法,可以将控制器添加到childViewControllers数组中
- [selfaddChildViewController:msg];
- [selfaddChildViewController:friends];
- [selfaddChildViewController:world];
- [selfaddChildViewController:setting];
- // 1.添加底部的标签栏(Dock)
- QQDock *dock = [[QQDock alloc] init];
- CGFloat dockH =49;
- CGFloat dockY =self.view.frame.size.height - dockH;
- CGFloat dockW =self.view.frame.size.width;
- CGFloat dockX =0;
- dock.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
- dock.frame = CGRectMake(dockX, dockY, dockW, dockH);
- dock.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tabbar_bg.png"]];
- dock.delegate =self;
- [self.view addSubview:dock];
- _dock = dock;
- // 2.添加Dock上的4个按钮
- // 2.1.消息
- [_dock addDockItem:@"消息"icon:@"tab_recent_nor.png"selectedIcon:@"tab_recent_press.png"];
- // 2.2.联系人
- [_dock addDockItem:@"联系人"icon:@"tab_buddy_nor.png"selectedIcon:@"tab_buddy_press.png"];
- // 2.3.动态
- [_dock addDockItem:@"动态"icon:@"tab_qworld_nor.png"selectedIcon:@"tab_qworld_press.png"];
- // 2.4.设置
- [_dock addDockItem:@"设置"icon:@"tab_me_nor.png"selectedIcon:@"tab_me_press.png"];
- // 3.设置导航栏主题
- //只要操作了appearance返回的对象,就相当于操作了整个项目中的UINavigationBar
- UINavigationBar *bar = [UINavigationBar appearance];
- // UIImage *image = [UIImage imageNamed:@"titlebar_bg.png"];
- //
- // image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
- [bar setBackgroundImage:[UIImage resizedImage:@"titlebar_bg.png"] forBarMetrics:UIBarMetricsDefault];
- [bar setTitleTextAttributes:@{
- // UITextAttributeFont : [UIFont systemFontOfSize:12]
- // UITextAttributeTextColor : [UIColor redColor]
- //UITextAttributeTextShadowColor : [UIColor blueColor],
- //UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(10, 10)]
- }];
- }
- #pragma mark - QQDock的代理方法
- - (void)dock:(QQDock *)dock didSelectedFromIndex:(int)from toIndex:(int)to
- {
- // 1.移除旧控制器的view
- UIViewController *oldVC =self.childViewControllers[from];
- [oldVC.view removeFromSuperview];
- // 2.添加新控制器的view
- UIViewController *newVC =self.childViewControllers[to];
- CGFloat viewW =self.view.frame.size.width;
- CGFloat viewH =self.view.frame.size.height - _dock.frame.size.height;
- newVC.view.frame = CGRectMake(0,0, viewW, viewH);
- [self.view addSubview:newVC.view];
- // 3.将新控制器的navigationItem属性值赋值给QQMainViewController
- // [self.navigationItem copyFromOther:newVC.navigationItem];
- [UINavigationItem copyFrom:newVC.navigationItem to:self.navigationItem];
- // self.navigationItem.rightBarButtonItem = newVC.navigationItem.rightBarButtonItem;
- // self.navigationItem.rightBarButtonItems = newVC.navigationItem.rightBarButtonItems;
- // self.navigationItem.leftBarButtonItem = newVC.navigationItem.leftBarButtonItem;
- // self.navigationItem.leftBarButtonItems = newVC.navigationItem.leftBarButtonItems;
- // self.navigationItem.title = newVC.navigationItem.title;
- // self.navigationItem.titleView = newVC.navigationItem.titleView;
- }
- @end
-
// QQMessageViewController.h
Map - //
- // QQMessageViewController.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQMessageViewController : UITableViewController
- @end
-
// QQMessageViewController.m
Map - //
- // QQMessageViewController.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQMessageViewController.h"
- #import"QQTestViewController.h"
- @interfaceQQMessageViewController ()
- @end
- @implementationQQMessageViewController
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- self.title =@"消息";
- }
- #pragma mark - Table view data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return20;
- }
- #pragma mark每一行显示怎样的cell(内容)
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // 1.定义一个标识
- staticNSString *ID =@"cell";
- // 2.去缓存池中取出可循环利用的cell
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- // 3.如果缓存中没有可循环利用的cell
- if(cell ==nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
- }
- cell.textLabel.text = [NSString stringWithFormat:@"消息---%d", indexPath.row];
- returncell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // NSLog(@"parent = %@, nav = %@", self.parentViewController, self.navigationController);
- QQTestViewController *test = [[QQTestViewController alloc] init];
- [self.navigationController pushViewController:test animated:YES];
- }
- @end
-
// QQSettingViewController.h
Map - //
- // QQSettingViewController.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQSettingViewController : UITableViewController
- @end
-
// QQSettingViewController.m
Map - //
- // QQSettingViewController.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQSettingViewController.h"
- @interfaceQQSettingViewController ()
- @end
- @implementationQQSettingViewController
- - (id)initWithStyle:(UITableViewStyle)style
- {
- self= [superinitWithStyle:style];
- if(self) {
- // Custom initialization
- }
- returnself;
- }
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- self.view.backgroundColor = [UIColor yellowColor];
- self.title =@"设置";
- }
- - (void)didReceiveMemoryWarning
- {
- [superdidReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- #warning Potentially incomplete method implementation.
- // Return the number of sections.
- return0;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- #warning Incomplete method implementation.
- // Return the number of rows in the section.
- return0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- staticNSString *CellIdentifier =@"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // Configure the cell...
- returncell;
- }
- /*
- // Override to support conditional editing of the table view.
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the specified item to be editable.
- return YES;
- }
- */
- /*
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
- */
- /*
- // Override to support rearranging the table view.
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
- {
- }
- */
- /*
- // Override to support conditional rearranging of the table view.
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the item to be re-orderable.
- return YES;
- }
- */
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];
- */
- }
- @end
-
// QQTestViewController.h
Map - //
- // QQTestViewController.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQTestViewController : UIViewController
- @end
-
// QQTestViewController.m
Map - //
- // QQTestViewController.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQTestViewController.h"
- @interfaceQQTestViewController ()
- @end
- @implementationQQTestViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self= [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if(self) {
- // Custom initialization
- }
- returnself;
- }
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- // Do any additional setup after loading the view.
- self.view.backgroundColor = [UIColor brownColor];
- }
- - (void)didReceiveMemoryWarning
- {
- [superdidReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
-
// QQWorldViewController.h
Map - //
- // QQWorldViewController.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceQQWorldViewController : UITableViewController
- @end
-
// QQWorldViewController.m
Map - //
- // QQWorldViewController.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"QQWorldViewController.h"
- @interfaceQQWorldViewController ()
- @end
- @implementationQQWorldViewController
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- self.view.backgroundColor = [UIColor redColor];
- self.title =@"动态";
- }
- - (void)didReceiveMemoryWarning
- {
- [superdidReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- #warning Potentially incomplete method implementation.
- // Return the number of sections.
- return0;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- #warning Incomplete method implementation.
- // Return the number of rows in the section.
- return0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- staticNSString *CellIdentifier =@"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // Configure the cell...
- returncell;
- }
- /*
- // Override to support conditional editing of the table view.
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the specified item to be editable.
- return YES;
- }
- */
- /*
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
- */
- /*
- // Override to support rearranging the table view.
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
- {
- }
- */
- /*
- // Override to support conditional rearranging of the table view.
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Return NO if you do not want the item to be re-orderable.
- return YES;
- }
- */
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];
- */
- }
- @end
-
// UIImage+QQ.h
Map - //
- // UIImage+QQ.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceUIImage (QQ)
- + (UIImage *)resizedImage:(NSString *)name;
- @end
-
// UIImage+QQ.m
Map - //
- // UIImage+QQ.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"UIImage+QQ.h"
- @implementationUIImage (QQ)
- + (UIImage *)resizedImage:(NSString *)name
- {
- UIImage *image = [UIImage imageNamed:name];
- return[image stretchableImageWithLeftCapWidth:image.size.width *0.5 topCapHeight:image.size.height *0.5];
- }
- @end
-
// UINavigationItem+QQ.h
Map - //
- // UINavigationItem+QQ.h
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceUINavigationItem (QQ)
- - (void)copyFromOther:(UINavigationItem *)other;
- + (void)copyFrom:(UINavigationItem *)from to:(UINavigationItem *)to;
- @end
-
// UINavigationItem+QQ.m
Map - //
- // UINavigationItem+QQ.m
- // 01-QQ
- //
- // Created by apple on 13-12-13.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"UINavigationItem+QQ.h"
- @implementationUINavigationItem (QQ)
- - (void)copyFromOther:(UINavigationItem *)other
- {
- self.rightBarButtonItem = other.rightBarButtonItem;
- self.rightBarButtonItems = other.rightBarButtonItems;
- self.leftBarButtonItem = other.leftBarButtonItem;
- self.leftBarButtonItems = other.leftBarButtonItems;
- self.title = other.title;
- self.titleView = other.titleView;
- }
- + (void)copyFrom:(UINavigationItem *)from to:(UINavigationItem *)to
- {
- [to copyFromOther:from];
- }
- @end
作者:
出处:http://www.cnblogs.com/ChenYilong/(点击RSS订阅)
本文版权归作者和博客园共有,欢迎转载,
但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。