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- 用MapKit和CoreLocation 来实现移动设备(地图与定位)
1.前言 发现在很多的社交软件都引入了地图和定位功能,如果我们要想实现这两大功能,需要利用到两个框架:MapKit和CoreLocation 我们先来看看CoreLocation框架: 它可以 ...
- iOS-根据两个经纬度计算相距距离
CLLocation *orig=[[[CLLocation alloc] initWithLatitude:[mainDelegate.latitude_self doubleValue] long ...
- NCAIOC
NCAIOC Npm Cli All In One Client https://github.com/xgqfrms/NCAIOC https://cdn.xgqfrms.xyz/web-ide/i ...
- 在DBGrid中可选中行而又可进入编辑状态
如何在DBGrid中选中行,而又让它可以进入编辑状态? 也许你会问我这有什么用?呵呵,做数据库应用的兄弟们会深有感触,当用DBGrid显示的字段过多时,用户不得不拉动最下面的滚动条,去看最右边的东西, ...
- Spring AOP 源码解析
什么是AOP AOP(Aspect-OrientedProgramming,面向方面编程),可以说是OOP(Object-Oriented Programing,面向对象编程)的补充和完善.OOP引入 ...
- Matlab中fspecial的用法【转】
Fspecial函数用于创建预定义的滤波算子,其语法格式为:h = fspecial(type)h = fspecial(type,parameters,sigma) 参数type制定算子类型,par ...
- 【bzoj2699】更新 dp
题目描述 对于一个数列A[1..N],一种寻找最大值的方法是:依次枚举A[2]到A[N],如果A[i]比当前的A[1]值要大,那么就令A[1]=A[i],最后A[1]为所求最大值.假设所有数都在范围[ ...
- 深入理解Delete(JavaScript)
深入理解Delete(JavaScript) Delete 众所周知是删除对象中的属性. 但如果不深入了解delete的真正使用在项目中会出现非常严重的问题 (: Following 是翻译 ka ...
- Unable to open connection to "Microsoft SQL Server, provider V1.0.5000.0 in framework
解决办法:1 以管理员身份登陆2 找到ORACLE_HOME文件夹(D:\oracle\ora92),点右键,选属性——安全,在组或用户栏中选"Authenticated Users&quo ...
- [JSOI2010]缓存交换 贪心 & 堆
~~~题面~~~ 题解: 首先我们要使得Miss的次数尽量少,也就是要尽量保证每个点在被访问的时候,这个点已经存在于Cache中. 那么我们可以得到一个结论: 如果Cache已满,那么我们就从Cach ...