01-QQ 3-最终重构版 Demo示例程序源代码
- 源代码下载链接:01-QQ 3.zip
292.5 KB // QQAppDelegate.h
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
- //
- // 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
01-QQ 3-最终重构版 Demo示例程序源代码的更多相关文章
- 03.WebView演练-iOS开发Demo(示例程序)源代码
技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http://weibo.com/luohanchenyilong //转载请注明出处--本文永久链接:h ...
- iOS多线程
iOS开发Demo(示例程序)源代码
本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址(2013年12月29日更新版) iOS程序源代码下载链接:01.大任务.zip22 ...
- 01-导航实例-QQ空间Demo示例程序源代码
01-导航实例-QQ空间.zip62.4 KB // MJLoginViewController.h Map // // MJLoginViewController.h // 01-导航实例-QQ ...
- 代理设计模式iOS开发Demo(示例程序)源代码
iOS程序源代码下载链接:03-代理设计模式.zip28.3 KB // main.m // // main.m // 03-代理设计模式 // // Created by apple ...
- 01-modal
Demo示例程序源代码
源代码下载链接:01-modal.zip37.8 KB // MJAppDelegate.h // // MJAppDelegate.h // 01-modal // // Created by ...
- 02-更改窗口的根控制器
Demo示例程序源代码
源代码下载链接:02-更改窗口的根控制器.zip18.0 KB // MJAppDelegate.h // // MJAppDelegate.h // 02-更改窗口的根控制器 // // ...
- 归档普通对象Demo示例程序源代码
源代码下载链接:06-归档普通对象.zip34.2 KB // MJPerson.h // // MJPerson.h // 06-归档普通对象 // // Created by apple o ...
- 发现中文版《C Primer Plus第五版》示例程序的一个错误
错误的程序出现再第17章的499页ListItemCount()和500页的Traverse()两个函数上. 原著包含所有函数定义的list.c如下: #include<stdio.h> ...
- 12.13记录//QQDemo示例程序源代码
笔记的完整版pdf文档下载地址: https://www.evernote.com/shard/s227/sh/ac692160-68c7-4149-83ea-0db5385e28b0 ...
随机推荐
- Java中I/O流之缓冲流
Java 中的缓冲流: 1. 缓冲流要“套接”在相应的节点流之上,对读写的数据提供了缓冲的功能,提高了读写的效率,同时增加了一些新的方法(带缓冲区的,显著减少对 IO 的读写次数,保护硬盘). 2. ...
- sigsuspend
1)头文件:#include <signal.h> 2)一个保护临界区代码的错误实例:(sigprocmask()和pause()实现) #include <unistd.h> ...
- 开发iOS百度地图大头针可以重复点击
[self.mapView deselectAnnotation:view.annotation animated:YES];
- iOS开发解决 jsonModel 属性跟系统的重复
-(id)initWithDic:(NSDictionary *)dic { if (self = [super init]) { [self setValuesForKeysWithDictiona ...
- linux核心版本号的说明
日志不会很长,因为每天都在学习,我认为的重点,我自己做的记录,我很高兴能分享给大家: Linux的核心版本编号有点类似如下癿样子: 2.6.18-92.el5 主版本.次版本.释出版本-修改版本 因为 ...
- ResultSet 可滚动性和可更新性
JDBC 2.0 API 为结果集增加了两个新的基本能力:可滚动性和可更新性,我想肯定满足了你的要求.在滚动结果集中可用的方法有: rs.previous();//向前滚动 rs.next();//向 ...
- [剑指Offer] 65.矩阵中的路径
题目描述 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径.路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子.如果一条路径经过了矩阵中 ...
- (sender as TButton).some 和 TButton(sender).some 的区别是什么?
(sender as TButton).some 和 TButton(sender).some 的区别是什么? (Sender as TButton) 与 TButton(Sender) 都是 Typ ...
- Dubbo和Spring Cloud开发框架对比
前言 微服务架构是互联网很热门的话题,是互联网技术发展的必然结果.它提倡将单一应用程序划分成一组小的服务,服务之间互相协调.互相配合,为用户提供最终价值.虽然微服务架构没有公认的技术标准和规范或者草案 ...
- NOI 97 (Vijos 1464)积木游戏(DP)
很普通的DP,设dp[i][j][k]为第i块积木放在第j堆且摆放状态为k的最高高度.方程很容易推出. # include <cstdio> # include <cstring&g ...