1. 源代码下载链接:01-QQ 3.zip
    292.5 KB
  2. // QQAppDelegate.h

    Map

  3. //
  4. //  QQAppDelegate.h
  5. //  01-QQ
  6. //
  7. //  Created by apple on 13-12-13.
  8. //  Copyright (c) 2013年itcast. All rights reserved.
  9. //
  10. #import<UIKit/UIKit.h>
  11. @interfaceQQAppDelegate : UIResponder <UIApplicationDelegate>
  12. @property(strong,nonatomic) UIWindow *window;
  13. @end
  14. // QQAppDelegate.m

    Map

  15. //
  16. //  QQAppDelegate.m
  17. //  01-QQ
  18. //
  19. //  Created by apple on 13-12-13.
  20. //  Copyright (c) 2013年itcast. All rights reserved.
  21. //
  22. #import"QQAppDelegate.h"
  23. #import"QQMainViewController.h"
  24. @implementationQQAppDelegate
  25. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  26. {
  27.    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  28.     QQMainViewController *main = [[QQMainViewController alloc] init];
  29.    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:main];
  30.    
  31. //    NSLog(@"%@", self.window.rootViewController);
  32.    
  33.     [self.window makeKeyAndVisible];
  34.    returnYES;
  35. }
  36. - (void)applicationWillResignActive:(UIApplication *)application
  37. {
  38.    // 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.
  39.    // 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.
  40. }
  41. - (void)applicationDidEnterBackground:(UIApplication *)application
  42. {
  43.    // 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.
  44.    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  45. }
  46. - (void)applicationWillEnterForeground:(UIApplication *)application
  47. {
  48.    // 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.
  49. }
  50. - (void)applicationDidBecomeActive:(UIApplication *)application
  51. {
  52.    // 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.
  53. }
  54. - (void)applicationWillTerminate:(UIApplication *)application
  55. {
  56.    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  57. }
  58. @end
  59. // QQDock.h

    Map

  60. //
  61. //  QQDock.h
  62. //  01-QQ
  63. //
  64. //  Created by apple on 13-12-13.
  65. //  Copyright (c) 2013年itcast. All rights reserved.
  66. //
  67. #import<UIKit/UIKit.h>
  68. @classQQDock;
  69. @protocolQQDockDelegate <NSObject>
  70. @optional
  71. - (void)dock:(QQDock *)dock didSelectedFromIndex:(int)from toIndex:(int)to;
  72. @end
  73. @interfaceQQDock : UIView
  74. #pragma mark添加一个Dock上的小按钮
  75. - (void)addDockItem:(NSString *)title icon:(NSString *)icon selectedIcon:(NSString *)selectedIcon;
  76. @property(nonatomic,weak)id<QQDockDelegate> delegate;
  77. @end
  78. // QQDock.m

    Map

  79. //
  80. //  QQDock.m
  81. //  01-QQ
  82. //
  83. //  Created by apple on 13-12-13.
  84. //  Copyright (c) 2013年itcast. All rights reserved.
  85. //
  86. #import"QQDock.h"
  87. #import"QQDockItem.h"
  88. @interfaceQQDock()
  89. {
  90.     QQDockItem *_selectedItem;
  91. }
  92. @end
  93. @implementationQQDock
  94. - (id)initWithFrame:(CGRect)frame
  95. {
  96.    self= [superinitWithFrame:frame];
  97.    if(self) {
  98.        // Initialization code
  99.     }
  100.    returnself;
  101. }
  102. #pragma mark添加一个Dock上的小按钮
  103. - (void)addDockItem:(NSString *)title icon:(NSString *)icon selectedIcon:(NSString *)selectedIcon
  104. {
  105.     QQDockItem *item = [QQDockItem buttonWithType:UIButtonTypeCustom];
  106.    //按钮的图标
  107.     [item setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
  108.     [item setImage:[UIImage imageNamed:selectedIcon] forState:UIControlStateSelected];
  109.    //按钮的文字
  110.     [item setTitle:title forState:UIControlStateNormal];
  111.    //监听按钮的点击(UIControlEventTouchDown一按下去就会触发点击事件)
  112.     [item addTarget:selfaction:@selector(itemClick:) forControlEvents:UIControlEventTouchDown];
  113.     [selfaddSubview:item];
  114.    
  115.    //取出所有的按钮,排列frame
  116.     [selfadjustItemFrames];
  117. }
  118. - (void)adjustItemFrames
  119. {
  120.    intcount =self.subviews.count;
  121.     CGFloat itemW =self.frame.size.width / count;
  122.     CGFloat itemH =self.frame.size.height;
  123.     CGFloat itemY =0;
  124.    for(inti =0; i<count; i++) {
  125.         CGFloat itemX = i * itemW;
  126.         QQDockItem *child =self.subviews[i];
  127.         child.frame = CGRectMake(itemX, itemY, itemW, itemH);
  128.        //绑定tag
  129.         child.tag = i;
  130.        
  131.        //按钮被选中时的背景图片
  132.         NSString *selectedBg =nil;
  133.        if(i ==0) {//最左边
  134.             selectedBg =@"tabbar_sel_left.png";
  135.            
  136.            //默认选中最左边的按钮(相当于点击了这个按钮)
  137.             [selfitemClick:child];
  138.         }elseif(i == count -1) {//最右边
  139.             selectedBg =@"tabbar_sel_right.png";
  140.         }else{//中间
  141.             selectedBg =@"tabbar_sel_middle.png";
  142.         }
  143.         [child setBackgroundImage:[UIImage imageNamed:selectedBg] forState:UIControlStateSelected];
  144.     }
  145. }
  146. - (void)itemClick:(QQDockItem *)item
  147. {
  148.    // 0.通知代理
  149.    if([_delegate respondsToSelector:@selector(dock:didSelectedFromIndex:toIndex:)])
  150.     {
  151.         [_delegate dock:selfdidSelectedFromIndex:_selectedItem.tag toIndex:item.tag];
  152.     }
  153.    
  154.    // 1.取消选中当前选中的按钮
  155.     _selectedItem.selected =NO;
  156.    
  157.    // 2.选中新点击的按钮
  158.     item.selected =YES;
  159.    
  160.    // 3.让新点击的按钮成为当前选中的按钮
  161.     _selectedItem = item;
  162. }
  163. @end
  164. // QQDockItem.h

    Map

  165. //
  166. //  QQDockItem.h
  167. //  01-QQ
  168. //
  169. //  Created by apple on 13-12-13.
  170. //  Copyright (c) 2013年itcast. All rights reserved.
  171. //
  172. #import<UIKit/UIKit.h>
  173. @interfaceQQDockItem : UIButton
  174. @end
  175. // QQDockItem.m

    Map

  176. //
  177. //  QQDockItem.m
  178. //  01-QQ
  179. //
  180. //  Created by apple on 13-12-13.
  181. //  Copyright (c) 2013年itcast. All rights reserved.
  182. //
  183. #import"QQDockItem.h"
  184. #define kImageScale0.6
  185. @implementationQQDockItem
  186. #pragma mark init方法内部默认会调用initWithFrame:
  187. - (id)initWithFrame:(CGRect)frame
  188. {
  189.    self= [superinitWithFrame:frame];
  190.    if(self) {
  191.        //里面的图片居中
  192.        self.imageView.contentMode = UIViewContentModeCenter;
  193.        //里面的文字居中
  194.        self.titleLabel.textAlignment = NSTextAlignmentCenter;
  195.        //文字字体
  196.        self.titleLabel.font = [UIFont systemFontOfSize:12];
  197.     }
  198.    returnself;
  199. }
  200. #pragma mark当按钮达到高亮状态的时候会调用,并且默认会在这个方法中进行高亮处理
  201. - (void)setHighlighted:(BOOL)highlighted { }
  202. #pragma mark设置内部imageView的frame
  203. - (CGRect)imageRectForContentRect:(CGRect)contentRect
  204. {
  205.     CGFloat imgW = contentRect.size.width;
  206.     CGFloat imgH = contentRect.size.height * kImageScale;
  207.    returnCGRectMake(0,0, imgW, imgH);
  208. }
  209. #pragma mark设置内部titleLabel的frame
  210. - (CGRect)titleRectForContentRect:(CGRect)contentRect
  211. {
  212.     CGFloat titleW = contentRect.size.width;
  213.     CGFloat titleY = contentRect.size.height * kImageScale;
  214.     CGFloat titleH = contentRect.size.height - titleY;
  215.    
  216.    returnCGRectMake(0, titleY, titleW, titleH);
  217. }
  218. @end
  219. // QQFriendsViewController.h

    Map

  220. //
  221. //  QQFriendsViewController.h
  222. //  01-QQ
  223. //
  224. //  Created by apple on 13-12-13.
  225. //  Copyright (c) 2013年itcast. All rights reserved.
  226. //
  227. #import<UIKit/UIKit.h>
  228. @interfaceQQFriendsViewController : UITableViewController
  229. @end
  230. // QQFriendsViewController.m

    Map

  231. //
  232. //  QQFriendsViewController.m
  233. //  01-QQ
  234. //
  235. //  Created by apple on 13-12-13.
  236. //  Copyright (c) 2013年itcast. All rights reserved.
  237. //
  238. #import"QQFriendsViewController.h"
  239. @interfaceQQFriendsViewController ()
  240. @end
  241. @implementationQQFriendsViewController
  242. - (void)viewDidLoad
  243. {
  244.     [superviewDidLoad];
  245.    
  246.    self.view.backgroundColor = [UIColor blueColor];
  247.    
  248.    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"添加"style:UIBarButtonItemStyleBordered target:nilaction:nil];
  249.    
  250.     UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"分组",@"全部"]];
  251.     segment.segmentedControlStyle = UISegmentedControlStyleBar;
  252.     segment.selectedSegmentIndex =0;
  253.    self.navigationItem.titleView = segment;
  254. }
  255. - (void)didReceiveMemoryWarning
  256. {
  257.     [superdidReceiveMemoryWarning];
  258.    // Dispose of any resources that can be recreated.
  259. }
  260. #pragma mark - Table view data source
  261. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  262. {
  263. #warning Potentially incomplete method implementation.
  264.    // Return the number of sections.
  265.    return0;
  266. }
  267. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  268. {
  269. #warning Incomplete method implementation.
  270.    // Return the number of rows in the section.
  271.    return0;
  272. }
  273. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  274. {
  275.    staticNSString *CellIdentifier =@"Cell";
  276.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  277.    
  278.    // Configure the cell...
  279.    
  280.    returncell;
  281. }
  282. /*
  283. // Override to support conditional editing of the table view.
  284. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  285. {
  286.     // Return NO if you do not want the specified item to be editable.
  287.     return YES;
  288. }
  289. */
  290. /*
  291. // Override to support editing the table view.
  292. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  293. {
  294.     if (editingStyle == UITableViewCellEditingStyleDelete) {
  295.         // Delete the row from the data source
  296.         [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
  297.     }  
  298.     else if (editingStyle == UITableViewCellEditingStyleInsert) {
  299.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  300.     }  
  301. }
  302. */
  303. /*
  304. // Override to support rearranging the table view.
  305. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
  306. {
  307. }
  308. */
  309. /*
  310. // Override to support conditional rearranging of the table view.
  311. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
  312. {
  313.     // Return NO if you do not want the item to be re-orderable.
  314.     return YES;
  315. }
  316. */
  317. #pragma mark - Table view delegate
  318. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  319. {
  320.    // Navigation logic may go here. Create and push another view controller.
  321.    /*
  322.      <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  323.      // ...
  324.      // Pass the selected object to the new view controller.
  325.      [self.navigationController pushViewController:detailViewController animated:YES];
  326.      */
  327. }
  328. @end
  329. // QQMainViewController.h

    Map

  330. //
  331. //  QQMainViewController.h
  332. //  01-QQ
  333. //
  334. //  Created by apple on 13-12-13.
  335. //  Copyright (c) 2013年itcast. All rights reserved.
  336. //
  337. #import<UIKit/UIKit.h>
  338. @interfaceQQMainViewController : UIViewController
  339. @end
  340. // QQMainViewController.m

    Map

  341. //
  342. //  QQMainViewController.m
  343. //  01-QQ
  344. //
  345. //  Created by apple on 13-12-13.
  346. //  Copyright (c) 2013年itcast. All rights reserved.
  347. //
  348. #import"QQMainViewController.h"
  349. #import"QQFriendsViewController.h"
  350. #import"QQMessageViewController.h"
  351. #import"QQSettingViewController.h"
  352. #import"QQWorldViewController.h"
  353. #import"UIImage+QQ.h"
  354. #import"UINavigationItem+QQ.h"
  355. #import"QQDock.h"
  356. @interfaceQQMainViewController () <QQDockDelegate>
  357. {
  358.     QQDock *_dock;
  359. //    NSArray *_allViewControllers; //所有需要显示的控制器
  360. }
  361. @end
  362. @implementationQQMainViewController
  363. - (void)viewDidLoad
  364. {
  365.     [superviewDidLoad];
  366.    
  367.    // 0.创建所有的小控制器
  368.     QQMessageViewController *msg = [[QQMessageViewController alloc] init];
  369.     QQFriendsViewController *friends = [[QQFriendsViewController alloc] init];
  370.     QQWorldViewController *world = [[QQWorldViewController alloc] init];
  371.     QQSettingViewController *setting = [[QQSettingViewController alloc] init];
  372.    
  373.    //当两个控制器互为父子关系的时候,它们的view一般也是互为父子关系
  374. //    self.childViewControllers
  375.    //通过addChildViewController方法,可以将控制器添加到childViewControllers数组中
  376.     [selfaddChildViewController:msg];
  377.     [selfaddChildViewController:friends];
  378.     [selfaddChildViewController:world];
  379.     [selfaddChildViewController:setting];
  380.    
  381.    // 1.添加底部的标签栏(Dock)
  382.     QQDock *dock = [[QQDock alloc] init];
  383.     CGFloat dockH =49;
  384.     CGFloat dockY =self.view.frame.size.height - dockH;
  385.     CGFloat dockW =self.view.frame.size.width;
  386.     CGFloat dockX =0;
  387.     dock.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
  388.     dock.frame = CGRectMake(dockX, dockY, dockW, dockH);
  389.     dock.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tabbar_bg.png"]];
  390.     dock.delegate =self;
  391.     [self.view addSubview:dock];
  392.     _dock = dock;
  393.    
  394.    // 2.添加Dock上的4个按钮
  395.    // 2.1.消息
  396.     [_dock addDockItem:@"消息"icon:@"tab_recent_nor.png"selectedIcon:@"tab_recent_press.png"];
  397.    // 2.2.联系人
  398.     [_dock addDockItem:@"联系人"icon:@"tab_buddy_nor.png"selectedIcon:@"tab_buddy_press.png"];
  399.    // 2.3.动态
  400.     [_dock addDockItem:@"动态"icon:@"tab_qworld_nor.png"selectedIcon:@"tab_qworld_press.png"];
  401.    // 2.4.设置
  402.     [_dock addDockItem:@"设置"icon:@"tab_me_nor.png"selectedIcon:@"tab_me_press.png"];
  403.    
  404.    // 3.设置导航栏主题
  405.    //只要操作了appearance返回的对象,就相当于操作了整个项目中的UINavigationBar
  406.     UINavigationBar *bar = [UINavigationBar appearance];
  407. //    UIImage *image = [UIImage imageNamed:@"titlebar_bg.png"];
  408. //   
  409. //    image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5  topCapHeight:image.size.height * 0.5];
  410.    
  411.     [bar setBackgroundImage:[UIImage resizedImage:@"titlebar_bg.png"] forBarMetrics:UIBarMetricsDefault];
  412.    
  413.     [bar setTitleTextAttributes:@{
  414. //           UITextAttributeFont : [UIFont systemFontOfSize:12]
  415. //        UITextAttributeTextColor : [UIColor redColor]
  416. //UITextAttributeTextShadowColor : [UIColor blueColor],
  417. //UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(10, 10)]
  418.     }];
  419. }
  420. #pragma mark - QQDock的代理方法
  421. - (void)dock:(QQDock *)dock didSelectedFromIndex:(int)from toIndex:(int)to
  422. {
  423.    // 1.移除旧控制器的view
  424.     UIViewController *oldVC =self.childViewControllers[from];
  425.     [oldVC.view removeFromSuperview];
  426.    
  427.    // 2.添加新控制器的view
  428.     UIViewController *newVC =self.childViewControllers[to];
  429.     CGFloat viewW =self.view.frame.size.width;
  430.     CGFloat viewH =self.view.frame.size.height - _dock.frame.size.height;
  431.     newVC.view.frame = CGRectMake(0,0, viewW, viewH);
  432.     [self.view addSubview:newVC.view];
  433.    
  434.    // 3.将新控制器的navigationItem属性值赋值给QQMainViewController
  435. //    [self.navigationItem copyFromOther:newVC.navigationItem];
  436.     [UINavigationItem copyFrom:newVC.navigationItem to:self.navigationItem];
  437.    
  438. //    self.navigationItem.rightBarButtonItem = newVC.navigationItem.rightBarButtonItem;
  439. //    self.navigationItem.rightBarButtonItems = newVC.navigationItem.rightBarButtonItems;
  440. //    self.navigationItem.leftBarButtonItem = newVC.navigationItem.leftBarButtonItem;
  441. //    self.navigationItem.leftBarButtonItems = newVC.navigationItem.leftBarButtonItems;
  442. //    self.navigationItem.title = newVC.navigationItem.title;
  443. //    self.navigationItem.titleView = newVC.navigationItem.titleView;
  444. }
  445. @end
  446. // QQMessageViewController.h

    Map

  447. //
  448. //  QQMessageViewController.h
  449. //  01-QQ
  450. //
  451. //  Created by apple on 13-12-13.
  452. //  Copyright (c) 2013年itcast. All rights reserved.
  453. //
  454. #import<UIKit/UIKit.h>
  455. @interfaceQQMessageViewController : UITableViewController
  456. @end
  457. // QQMessageViewController.m

    Map

  458. //
  459. //  QQMessageViewController.m
  460. //  01-QQ
  461. //
  462. //  Created by apple on 13-12-13.
  463. //  Copyright (c) 2013年itcast. All rights reserved.
  464. //
  465. #import"QQMessageViewController.h"
  466. #import"QQTestViewController.h"
  467. @interfaceQQMessageViewController ()
  468. @end
  469. @implementationQQMessageViewController
  470. - (void)viewDidLoad
  471. {
  472.     [superviewDidLoad];
  473.    
  474.    self.title =@"消息";
  475. }
  476. #pragma mark - Table view data source
  477. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  478. {
  479.    return20;
  480. }
  481. #pragma mark每一行显示怎样的cell(内容)
  482. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  483. {
  484.    // 1.定义一个标识
  485.    staticNSString *ID =@"cell";
  486.    
  487.    // 2.去缓存池中取出可循环利用的cell
  488.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  489.    
  490.    // 3.如果缓存中没有可循环利用的cell
  491.    if(cell ==nil) {
  492.         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  493.     }
  494.    
  495.     cell.textLabel.text = [NSString stringWithFormat:@"消息---%d", indexPath.row];
  496.    
  497.    returncell;
  498. }
  499. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  500. {
  501. //    NSLog(@"parent = %@, nav = %@", self.parentViewController, self.navigationController);
  502.     QQTestViewController *test = [[QQTestViewController alloc] init];
  503.     [self.navigationController pushViewController:test animated:YES];
  504. }
  505. @end
  506. // QQSettingViewController.h

    Map

  507. //
  508. //  QQSettingViewController.h
  509. //  01-QQ
  510. //
  511. //  Created by apple on 13-12-13.
  512. //  Copyright (c) 2013年itcast. All rights reserved.
  513. //
  514. #import<UIKit/UIKit.h>
  515. @interfaceQQSettingViewController : UITableViewController
  516. @end
  517. // QQSettingViewController.m

    Map

  518. //
  519. //  QQSettingViewController.m
  520. //  01-QQ
  521. //
  522. //  Created by apple on 13-12-13.
  523. //  Copyright (c) 2013年itcast. All rights reserved.
  524. //
  525. #import"QQSettingViewController.h"
  526. @interfaceQQSettingViewController ()
  527. @end
  528. @implementationQQSettingViewController
  529. - (id)initWithStyle:(UITableViewStyle)style
  530. {
  531.    self= [superinitWithStyle:style];
  532.    if(self) {
  533.        // Custom initialization
  534.     }
  535.    returnself;
  536. }
  537. - (void)viewDidLoad
  538. {
  539.     [superviewDidLoad];
  540.    
  541.    self.view.backgroundColor = [UIColor yellowColor];
  542.    
  543.    self.title =@"设置";
  544. }
  545. - (void)didReceiveMemoryWarning
  546. {
  547.     [superdidReceiveMemoryWarning];
  548.    // Dispose of any resources that can be recreated.
  549. }
  550. #pragma mark - Table view data source
  551. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  552. {
  553. #warning Potentially incomplete method implementation.
  554.    // Return the number of sections.
  555.    return0;
  556. }
  557. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  558. {
  559. #warning Incomplete method implementation.
  560.    // Return the number of rows in the section.
  561.    return0;
  562. }
  563. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  564. {
  565.    staticNSString *CellIdentifier =@"Cell";
  566.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  567.    
  568.    // Configure the cell...
  569.    
  570.    returncell;
  571. }
  572. /*
  573. // Override to support conditional editing of the table view.
  574. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  575. {
  576.     // Return NO if you do not want the specified item to be editable.
  577.     return YES;
  578. }
  579. */
  580. /*
  581. // Override to support editing the table view.
  582. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  583. {
  584.     if (editingStyle == UITableViewCellEditingStyleDelete) {
  585.         // Delete the row from the data source
  586.         [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
  587.     }  
  588.     else if (editingStyle == UITableViewCellEditingStyleInsert) {
  589.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  590.     }  
  591. }
  592. */
  593. /*
  594. // Override to support rearranging the table view.
  595. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
  596. {
  597. }
  598. */
  599. /*
  600. // Override to support conditional rearranging of the table view.
  601. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
  602. {
  603.     // Return NO if you do not want the item to be re-orderable.
  604.     return YES;
  605. }
  606. */
  607. #pragma mark - Table view delegate
  608. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  609. {
  610.    // Navigation logic may go here. Create and push another view controller.
  611.    /*
  612.      <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  613.      // ...
  614.      // Pass the selected object to the new view controller.
  615.      [self.navigationController pushViewController:detailViewController animated:YES];
  616.      */
  617. }
  618. @end
  619. // QQTestViewController.h

    Map

  620. //
  621. //  QQTestViewController.h
  622. //  01-QQ
  623. //
  624. //  Created by apple on 13-12-13.
  625. //  Copyright (c) 2013年itcast. All rights reserved.
  626. //
  627. #import<UIKit/UIKit.h>
  628. @interfaceQQTestViewController : UIViewController
  629. @end
  630. // QQTestViewController.m

    Map

  631. //
  632. //  QQTestViewController.m
  633. //  01-QQ
  634. //
  635. //  Created by apple on 13-12-13.
  636. //  Copyright (c) 2013年itcast. All rights reserved.
  637. //
  638. #import"QQTestViewController.h"
  639. @interfaceQQTestViewController ()
  640. @end
  641. @implementationQQTestViewController
  642. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  643. {
  644.    self= [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  645.    if(self) {
  646.        // Custom initialization
  647.     }
  648.    returnself;
  649. }
  650. - (void)viewDidLoad
  651. {
  652.     [superviewDidLoad];
  653. // Do any additional setup after loading the view.
  654.    
  655.    self.view.backgroundColor = [UIColor brownColor];
  656. }
  657. - (void)didReceiveMemoryWarning
  658. {
  659.     [superdidReceiveMemoryWarning];
  660.    // Dispose of any resources that can be recreated.
  661. }
  662. @end
  663. // QQWorldViewController.h

    Map

  664. //
  665. //  QQWorldViewController.h
  666. //  01-QQ
  667. //
  668. //  Created by apple on 13-12-13.
  669. //  Copyright (c) 2013年itcast. All rights reserved.
  670. //
  671. #import<UIKit/UIKit.h>
  672. @interfaceQQWorldViewController : UITableViewController
  673. @end
  674. // QQWorldViewController.m

    Map

  675. //
  676. //  QQWorldViewController.m
  677. //  01-QQ
  678. //
  679. //  Created by apple on 13-12-13.
  680. //  Copyright (c) 2013年itcast. All rights reserved.
  681. //
  682. #import"QQWorldViewController.h"
  683. @interfaceQQWorldViewController ()
  684. @end
  685. @implementationQQWorldViewController
  686. - (void)viewDidLoad
  687. {
  688.     [superviewDidLoad];
  689.    
  690.    self.view.backgroundColor = [UIColor redColor];
  691.    
  692.    self.title =@"动态";
  693. }
  694. - (void)didReceiveMemoryWarning
  695. {
  696.     [superdidReceiveMemoryWarning];
  697.    // Dispose of any resources that can be recreated.
  698. }
  699. #pragma mark - Table view data source
  700. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  701. {
  702. #warning Potentially incomplete method implementation.
  703.    // Return the number of sections.
  704.    return0;
  705. }
  706. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  707. {
  708. #warning Incomplete method implementation.
  709.    // Return the number of rows in the section.
  710.    return0;
  711. }
  712. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  713. {
  714.    staticNSString *CellIdentifier =@"Cell";
  715.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  716.    
  717.    // Configure the cell...
  718.    
  719.    returncell;
  720. }
  721. /*
  722. // Override to support conditional editing of the table view.
  723. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  724. {
  725.     // Return NO if you do not want the specified item to be editable.
  726.     return YES;
  727. }
  728. */
  729. /*
  730. // Override to support editing the table view.
  731. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  732. {
  733.     if (editingStyle == UITableViewCellEditingStyleDelete) {
  734.         // Delete the row from the data source
  735.         [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
  736.     }  
  737.     else if (editingStyle == UITableViewCellEditingStyleInsert) {
  738.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  739.     }  
  740. }
  741. */
  742. /*
  743. // Override to support rearranging the table view.
  744. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
  745. {
  746. }
  747. */
  748. /*
  749. // Override to support conditional rearranging of the table view.
  750. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
  751. {
  752.     // Return NO if you do not want the item to be re-orderable.
  753.     return YES;
  754. }
  755. */
  756. #pragma mark - Table view delegate
  757. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  758. {
  759.    // Navigation logic may go here. Create and push another view controller.
  760.    /*
  761.      <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  762.      // ...
  763.      // Pass the selected object to the new view controller.
  764.      [self.navigationController pushViewController:detailViewController animated:YES];
  765.      */
  766. }
  767. @end
  768. // UIImage+QQ.h

    Map

  769. //
  770. //  UIImage+QQ.h
  771. //  01-QQ
  772. //
  773. //  Created by apple on 13-12-13.
  774. //  Copyright (c) 2013年itcast. All rights reserved.
  775. //
  776. #import<UIKit/UIKit.h>
  777. @interfaceUIImage (QQ)
  778. + (UIImage *)resizedImage:(NSString *)name;
  779. @end
  780. // UIImage+QQ.m

    Map

  781. //
  782. //  UIImage+QQ.m
  783. //  01-QQ
  784. //
  785. //  Created by apple on 13-12-13.
  786. //  Copyright (c) 2013年itcast. All rights reserved.
  787. //
  788. #import"UIImage+QQ.h"
  789. @implementationUIImage (QQ)
  790. + (UIImage *)resizedImage:(NSString *)name
  791. {
  792.     UIImage *image = [UIImage imageNamed:name];
  793.    
  794.    return[image stretchableImageWithLeftCapWidth:image.size.width *0.5  topCapHeight:image.size.height *0.5];
  795. }
  796. @end
  797. // UINavigationItem+QQ.h

    Map

  798. //
  799. //  UINavigationItem+QQ.h
  800. //  01-QQ
  801. //
  802. //  Created by apple on 13-12-13.
  803. //  Copyright (c) 2013年itcast. All rights reserved.
  804. //
  805. #import<UIKit/UIKit.h>
  806. @interfaceUINavigationItem (QQ)
  807. - (void)copyFromOther:(UINavigationItem *)other;
  808. + (void)copyFrom:(UINavigationItem *)from to:(UINavigationItem *)to;
  809. @end
  810. // UINavigationItem+QQ.m

    Map

  811. //
  812. //  UINavigationItem+QQ.m
  813. //  01-QQ
  814. //
  815. //  Created by apple on 13-12-13.
  816. //  Copyright (c) 2013年itcast. All rights reserved.
  817. //
  818. #import"UINavigationItem+QQ.h"
  819. @implementationUINavigationItem (QQ)
  820. - (void)copyFromOther:(UINavigationItem *)other
  821. {
  822.    self.rightBarButtonItem = other.rightBarButtonItem;
  823.    self.rightBarButtonItems = other.rightBarButtonItems;
  824.    self.leftBarButtonItem = other.leftBarButtonItem;
  825.    self.leftBarButtonItems = other.leftBarButtonItems;
  826.    self.title = other.title;
  827.    self.titleView = other.titleView;
  828. }
  829. + (void)copyFrom:(UINavigationItem *)from to:(UINavigationItem *)to
  830. {
  831.     [to copyFromOther:from];
  832. }
  833. @end

 

https://www.evernote.com/shard/s227/sh/5f4fbf17-106c-442f-8ea9-639de08377b9/561462b4104b0d33529325f0f9840346

01-QQ 3-最终重构版 Demo示例程序源代码的更多相关文章

  1. 03.WebView演练-iOS开发Demo(示例程序)源代码

    技术博客http://www.cnblogs.com/ChenYilong/   新浪微博http://weibo.com/luohanchenyilong   //转载请注明出处--本文永久链接:h ...

  2. iOS多线程 iOS开发Demo(示例程序)源代码

    本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址(2013年12月29日更新版)   iOS程序源代码下载链接:01.大任务.zip22 ...

  3. 01-导航实例-QQ空间Demo示例程序源代码

    01-导航实例-QQ空间.zip62.4 KB // MJLoginViewController.h Map // //  MJLoginViewController.h //  01-导航实例-QQ ...

  4. 代理设计模式iOS开发Demo(示例程序)源代码

        iOS程序源代码下载链接:03-代理设计模式.zip28.3 KB // main.m // //  main.m //  03-代理设计模式 // //  Created by apple ...

  5. 01-modal Demo示例程序源代码

    源代码下载链接:01-modal.zip37.8 KB // MJAppDelegate.h // //  MJAppDelegate.h //  01-modal // //  Created by ...

  6. 02-更改窗口的根控制器 Demo示例程序源代码

      源代码下载链接:02-更改窗口的根控制器.zip18.0 KB // MJAppDelegate.h // //  MJAppDelegate.h //  02-更改窗口的根控制器 // //  ...

  7. 归档普通对象Demo示例程序源代码

    源代码下载链接:06-归档普通对象.zip34.2 KB // MJPerson.h // //  MJPerson.h //  06-归档普通对象 // //  Created by apple o ...

  8. 发现中文版《C Primer Plus第五版》示例程序的一个错误

    错误的程序出现再第17章的499页ListItemCount()和500页的Traverse()两个函数上. 原著包含所有函数定义的list.c如下: #include<stdio.h> ...

  9. 12.13记录//QQDemo示例程序源代码

            笔记的完整版pdf文档下载地址: https://www.evernote.com/shard/s227/sh/ac692160-68c7-4149-83ea-0db5385e28b0 ...

随机推荐

  1. com技术学习

    百度百科概念 COM是微软公司为了计算机工业的软件生产更加符合人类的行为方式开发的一种新的软件开发技术.在COM构架下,人们可以开发出各种各样的功能专一的组件,然后将它们按照需要组合起来,构成复杂的应 ...

  2. 3ds Max学习日记(六)

      到了周六就不想再忙实验室的活了,于是玩了一下3ds max,第5和第6章每章都只有4个视频,于是就一起弄完了,什么网格建模,曲面建模啥的,nurbs啥的. 附上今日的劳动成果:   叉子(用长方体 ...

  3. [剑指Offer] 55.链表中环的入口结点

    题目描述 一个链表中包含环,请找出该链表的环的入口结点. [思路]根据set集合的不重复,遍历链表时遇到的第一个重复结点就是环的入口结点. /* struct ListNode { int val; ...

  4. Matlab中save与load函数的使用

    用save函数,可以将工作空间的变量保存成txt文件或mat文件等. 比如: save peng.mat p j 就是将工作空间中的p和j变量保存在peng.mat中. 用load函数,可以将数据读入 ...

  5. mac终端命令-----常规操作

    OSX 的文件系统 OSX 采用的Unix文件系统,所有文件都挂在跟目录 / 下面,所以不在要有Windows 下的盘符概念. 你在桌面上看到的硬盘都挂在 /Volumes 下. 比如接上个叫做 US ...

  6. WPF 进度条ProgressBar

    今天研究了一下wpf的进度条ProgressBar 1.传统ProgressBar WPF进度条ProgressBar 这个控件,如果直接写到循环里,会死掉,界面会卡死,不会有进度.需要把进度条放到单 ...

  7. Necklace - CF613C

    Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of b ...

  8. [BZOJ4942] [NOI2017]整数

    题目背景 在人类智慧的山巅,有着一台字长为1048576位(此数字与解题无关)的超级计算机,著名理论计算机科 学家P博士正用它进行各种研究.不幸的是,这天台风切断了电力系统,超级计算机 无法工作,而 ...

  9. Codeforces Round #469 (Div. 2) F. Curfew

    贪心 题目大意,有2个宿管分别从1和n开始检查房间,记录人数不为n的房间个数,然后锁住房间. 没有被锁的房间中的学生可以选择藏在床底,留在原地,或者转移(最远转移d个房间)   然后抄了网上大神的代码 ...

  10. [ZJOJ2007]时态同步 贪心

    不是很懂为什么luogu标签是树形DP,感觉我想的就是一个贪心啊... 随机造几组数据,我们发现贪心的确可以得到最优解,那么为什么呢? 假设将所有时态贪心的调整是对的,那么如果一个节点的各个儿子时态不 ...