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 ...
随机推荐
- android 出现Make sure the Cursor is initialized correctly before accessing data from it
Make sure the Cursor is initialized correctly before accessing data from it 详细错误是:java.lang.IllegalS ...
- iOS开发给UIView添加动画Animation
self.testView需要添加动画的view 1.翻转动画 [UIView beginAnimations:@"doflip" context:nil]; [UIView se ...
- Jenkins系列-Jenkins添加git密钥对
添加密钥 1.添加git用户和git密码对 ,用于git客户端从gitlab上拉取代码到本地
- Windows Server 2012四大版本介绍
今天刚好要尝试安装Windows Server 2012,在网上百度了下发现有4个版本,分别是: Datacenter数据中心版. Standard标准版. Essentials版. Foundati ...
- java 堆和栈的区别
1,在栈中存放的是基本类型变量和对象的引用变量,当一段代码定义一个变量时,java 就在栈内为这个变量分配内存空间,当超过变量的作用域时,java会自动回收分配的内存. 局部变量在栈内存 2,堆内存放 ...
- Android------BottonTabBar
前言:一款简单好用封装好的AndroidUI控件,底部导航栏. 1.使用 1.1添加 compile 'com.hjm:BottomTabBar:1.1.1' 1.2 activity_main. ...
- Android基础------通知栏
前言:Android通知栏提示笔记 通知几乎是每一款app都拥有的功能 1.发送通知 发送一个通知栏必须用到两个类: NotificationManager . Notification. Noti ...
- BZOJ 1491 社交网络(最短路)
对于这道题,如果我们能求出s到t的最短路径数目和s由v到t的最短路径数目,剩下的很好求了. 令dis[i][j]表示i到j的最短路径,dp[i][j]表示i到j的最短路径条数,如果dis[s][v]+ ...
- OpenCV2.3.1在Win7+VS2010下的配置过程
1. 假定电脑上已经安装了VS2010程序,若没有,首先安装vs2010.下载OpenCV2.3.1,网址:http://sourceforge.net/projects/opencvlibrary ...
- Urllib--爬虫
1.简单爬虫 from urllib import request def f(url): print('GET: %s' % url) resp = request.urlopen(url) #赋给 ...