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 ...
随机推荐
- iOS-【UIDynamic-UIKit动力学】
如果看不到图片 可以尝试更换浏览器(推荐Safari ) 0.了解 •Dynamic Animator:动画者,为动力学元素提供物理学相关的能力及动画,同时为这些元素提供相关的上下文,是动力学元素与底 ...
- MongoDb Driver For Net
由于mongodb开源github提供的net驱动都比较新,从2.3及以上版本都是netcore系列了,netframework至少都是4.6以上,且提供的dll并没有签名, 这就产生了一些问题 1 ...
- web 性能测试与报告
web性能测试大家第一都会想到:loadrunner.ab.siege.http_load等工具.但是这些工具生成的测试报告都不是我想要的. 这里给大家推荐一个sitespeed,使用简单,生成非常详 ...
- 【题解】SDOI2017树点涂色
LCT强强!以前总是觉得LCT非常的难懂(当然现在也是的),但实际上它真的是很厉害的一种东西.它是一种动态的链剖分结构,其实就是对于剖分出来的重链使用LCT去进行维护.cut 与 link 两个操作让 ...
- Android 解决setRequestedOrientation之后手机屏幕的旋转不触发onConfigurationChanged方法
最近在做播放器的时候遇到一个问题,在屏幕方向改变之后需要切换播放器全屏/非全屏的时候,在重写了onConfigurationChanged方法并在manifest.xml配置文件中添加 android ...
- BZOJ3709 [PA2014]Bohater 【贪心】
题目链接 BZOJ3709 题解 贪心很显然 我们先干掉能回血的怪,当然按照\(d\)升序顺序,因为打得越多血越多,\(d\)大的尽量往后打 然后再干掉会扣血的怪,当然按照\(a\)降序顺序,因为最后 ...
- BZOJ1042 [HAOI2008]硬币购物 【完全背包 + 容斥】
1042: [HAOI2008]硬币购物 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2924 Solved: 1802 [Submit][St ...
- 2 Advanced Read/Write Splitting with PHP’s MySQLnd
原文地址需FQ才能看 https://blog.engineyard.com/2014/advanced-read-write-splitting-with-phps-mysqlnd In part ...
- ACE线程管理机制-面向对象的线程类ACE_Task
转载于:http://www.cnblogs.com/TianFang/archive/2006/12/05/583231.html 我们在前一章中使用ACE_Thread包装时,你一定已经注意到了一 ...
- 跨平台sdk接入总结
sdk说明: 1.Bugly SDK:自动捕获上报App的脚本错误和原生代码引发的崩溃信息,并提供异常问题分类分析. 2.语音 SDK:提供游戏内收发语音功能. 接入步骤: step1:仔细通读一遍s ...