ÀÖÓãµç¾º

½ÌÓýÐÐÒµA¹ÉIPOµÚÒ»¹É£¨¹ÉƱ´úÂë 003032£©

È«¹ú×Éѯ/ͶËßÈÈÏߣº400-618-4000

IOSÅàѵʵս½Ì³ÌÖ®¿ª·¢µÄ22¸öÆæÝâ¼¼ÇÉ

¸üÐÂʱ¼ä:2016Äê01ÔÂ27ÈÕ11ʱ11·Ö À´Ô´:ÀÖÓã²¥¿ÍIOSÅàѵѧԺ ä¯ÀÀ´ÎÊý:

µ¼¶Á£ºTableView²»ÏÔʾûÄÚÈݵÄCellÔõô°ì£¿¼üÅÌʼþдµÃºÃ·³Ô꣬¶¼Ïëˤ¼üÅÌÁËÔõô°ì£¿AppÀϲ»Á÷³©ÄijöÎÊÌâÁË£¿CoreDataÓï·¨ÓÖ³ôÓÖ³¤Ôõô°ì£¿À­ÉìͼƬÔõô²ÅÄܲ»±äÐΣ¿ÈÃÎÒÃÇÒ»Æð»¶ÀÖµØÔÚIOSÅàѵѧԺÖÐѧϰһÏÂiOS¿ª·¢µÄ¸÷ÖÖС¼¼ÇɰÉ¡£

1. TableView²»ÏÔʾûÄÚÈݵÄCellÔõô°ì£¿

ÀàËÆÓÚͼ1£¬ÎÒ²»ÏëÈÃÏÂÃæµÄÄÇЩ¿ÕÏÔʾ¡£ºÜ¼òµ¥£¬Ìí¼Ó“self.tableView.tableFooterView = [[UIView alloc] init];”ÊÔ¹ý¶¼ËµºÃ£¬¼ÓÍêÕâ¾äÖ®ºó¾Í±ä³ÉÁËͼ2µÄÑù×Ó¡£

2. ×Ô¶¨ÒåÁËleftBarbuttonItem×󻬷µ»ØÊÖÊÆÊ§Ð§ÁËÔõô°ì£¿

  1. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]  
  2.               initWithImage:img  
  3.               style:UIBarButtonItemStylePlain  
  4.               target:self  
  5.               action:@selector(onBack:)];  
  6. self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIG
¸´ÖÆ´úÂë


3. ScrollViewĪÃûÆäÃî²»ÄÜÔÚviewController»®µ½¶¥Ôõô°ì£¿

  1. self.automaticallyAdjustsScrollViewInsets = NO;  
¸´ÖÆ´úÂë

4. ¼üÅÌʼþдµÃºÃ·³Ô꣬¶¼Ïëˤ¼üÅÌÁËÔõô°ì£¿


  • Âò¸ö½áʵµÄ¼üÅÌ£»
  • ʹÓÃIQKeyboardManager£¨GitHubÉÏ¿ÉËÑË÷£©£¬ÓÃÍêÖ®ºóÑüÒ²²»ÌÛÁË£¬ÍÈÒ²²»ËáÁË¡£

5. ΪʲôÎÒµÄAppÀÏÊDz»Á÷³©£¬µ½µ×ÄÄÀï³öÁËÎÊÌ⣿

Èçͼ£º

Õâ¸öÉñÆ÷½Ð×ö£ºKMCGeigerCounter £¬¿ìÈ¥GitHubÉϰáÔ˰É¡£

6. ÔõôÔÚ²»Ð½¨Ò»¸öCellµÄÇé¿öϵ÷ÕûseparaLineµÄλÖã¿

  1. _myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);  
¸´ÖÆ´úÂë

7. Ôõôµã»÷self.view¾ÍÈüüÅÌÊÕÆð£¬ÐèÒªÌí¼ÓÒ»¸ötapGesturesô£¿

  1. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event  
  2. {  
  3.    [self.view endEditing:YES];  
  4. }  
¸´ÖÆ´úÂë


8. Ôõô¸øÃ¿¸öViewControllerÉ趨ĬÈϵı³¾°Í¼Æ¬£¿

ʹÓûùÀà°¡£¬ÉÙÄê¡£

9. ÏëÔÚ´úÂëÀï¸ÄÔÚxibÀïÌí¼ÓµÄlayoutAttributes£¬µ«¸ÃÔõôÓôúÂëÕÒ£¿

ÏñÀ­ButtonÒ»ÑùµØÀ­ÄãµÄÔ¼Êø£¬nslayoutattributeÒ²ÊÇ¿ÉÒÔÀ­Ïߵġ£

10. ÔõôÏñSafariÒ»Ñù»¬¶¯µÄʱºòÒþ²Ønavigationbar£¿

  1. navigationController.hidesBarsOnSwipe = Yes
¸´ÖÆ´úÂë

11. µ¼º½Ìõ·µ»Ø¼ü´øµÄtitleÌ«ÌÖÑáÁË£¬ÔõôÈÃËüÏûʧ£¿

  1. [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)  
  2.                                                      forBarMetrics:UIBarMetricsDefault];
¸´ÖÆ´úÂë

12. CoreDataÓÃÆðÀ´ºÃ·³£¬Óï·¨ÓÖ³ôÓÖ³¤Ôõô°ì£¿

MagicRecord

13. CollectionViewÔõôʵÏÖtableviewÄÇÖÖÐüÍ£µÄheader£¿

CSStickyHeaderFlowLayout

14. Äܲ»ÄÜÖ»ÓÃÒ»¸öpanÊÖÊÆÀ´´úÌæUISwipegestureµÄ¸÷¸ö·½Ïò£¿

  1. - (void)pan:(UIPanGestureRecognizer *)sender  
  2. {  
  3. typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) {  
  4.     UIPanGestureRecognizerDirectionUndefined,  
  5.     UIPanGestureRecognizerDirectionUp,  
  6.     UIPanGestureRecognizerDirectionDown,  
  7.     UIPanGestureRecognizerDirectionLeft,  
  8.     UIPanGestureRecognizerDirectionRight  
  9. };  
  10. static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined;  
  11. switch (sender.state) {  
  12.     case UIGestureRecognizerStateBegan: {  
  13.         if (direction == UIPanGestureRecognizerDirectionUndefined) {  
  14.             CGPoint velocity = [sender velocityInView:recognizer.view];  
  15.             BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x);  
  16.             if (isVerticalGesture) {  
  17.                 if (velocity.y > 0) {  
  18.                     direction = UIPanGestureRecognizerDirectionDown;  
  19.                 } else {  
  20.                     direction = UIPanGestureRecognizerDirectionUp;  
  21.                 }  
  22.             }  
  23.             else {  
  24.                 if (velocity.x > 0) {  
  25.                     direction = UIPanGestureRecognizerDirectionRight;  
  26.                 } else {  
  27.                     direction = UIPanGestureRecognizerDirectionLeft;  
  28.                 }  
  29.             }  
  30.         }  
  31.         break;  
  32.     }  
  33.     case UIGestureRecognizerStateChanged: {  
  34.         switch (direction) {  
  35.             case UIPanGestureRecognizerDirectionUp: {  
  36.                 [self handleUpwardsGesture:sender];  
  37.                 break;  
  38.             }  
  39.             case UIPanGestureRecognizerDirectionDown: {  
  40.                 [self handleDownwardsGesture:sender];  
  41.                 break;  
  42.             }  
  43.             case UIPanGestureRecognizerDirectionLeft: {  
  44.                 [self handleLeftGesture:sender];  
  45.                 break;  
  46.             }  
  47.             case UIPanGestureRecognizerDirectionRight: {  
  48.                 [self handleRightGesture:sender];  
  49.                 break;  
  50.             }  
  51.             default: {  
  52.                 break;  
  53.             }  
  54.         }  
  55.         break;  
  56.     }  
  57.     case UIGestureRecognizerStateEnded: {  
  58.         direction = UIPanGestureRecognizerDirectionUndefined;     
  59.         break;  
  60.     }  
  61.     default:  
  62.         break;  
  63. }  
  64. }  
¸´ÖÆ´úÂë




15. À­ÉìͼƬµÄʱºòÔõô²ÅÄÜÈÃͼƬ²»±äÐΣ¿

·½·¨Ò»£º

  1. UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];  
¸´ÖÆ´úÂë


×¢£ºÓпª·¢ÕßÌáÐÑÕâ¸öÒѾ­ÆúÓã¬ÏÖÔڵķ½·¨½ÐresizableImageWithCapInsets¡£

·½·¨¶þ£¬Èçͼ£º

16. Ôõô²¥·ÅGIFµÄʱºòÕâô¿¨£¬ÓÐûÓкõãµÄ¿â£¿

FlipBoard³öÆ·µÄFLAnimatedImageÌ«ÊʺÏÄãÁË¡£

17. Ôõôһ¾ä»°Ìí¼ÓÉÏÀ­Ë¢Ð£¿

ʹÓÃSVPullToRefresh¿â£º

  1. [tableView addPullToRefreshWithActionHandler:^{  
  2. // prepend data to dataSource, insert cells at top of table view  
  3. // call [tableView.pullToRefreshView stopAnimating] when done  
  4. } position:SVPullToRefreshPositionBottom];  
¸´ÖÆ´úÂë




18. Ôõô°ÑtableviewÀïCellµÄС¶Ô¹´ÑÕÉ«¸Ä³É±ðµÄÑÕÉ«£¿

  1. _mTableView.tintColor = [UIColor redColor];  
¸´ÖÆ´úÂë




19. ±¾À´ÎÒµÄstatusbarÊÇlightcontentµÄ£¬½á¹ûÓÃUIImagePickerController»áµ¼ÖÂÎÒµÄstatusbarµÄÑùʽ±ä³ÉºÚÉ«£¬Ôõô°ì£¿

  1. - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated  
  2. {  
  3.     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];  
  4. }  
¸´ÖÆ´úÂë

20. Ôõô°ÑÎÒµÄnavigationbarŪ³É͸Ã÷µÄ¶ø²»ÊÇ´øÄ£ºýµÄЧ¹û£¿

  1. [self.navigationBar setBackgroundImage:[UIImage new]  
  2.                          forBarMetrics:UIBarMetricsDefault];  
  3. self.navigationBar.shadowImage = [UIImage new];  
  4. self.navigationBar.translucent = YES;  
¸´ÖÆ´úÂë




21. Ôõô¸Ä±äuitextfield placeholderµÄÑÕÉ«ºÍλÖã¿

¼Ì³Ðuitextfield£¬ÖØÐ´Õâ¸ö·½·¨£º

  1. - (void) drawPlaceholderInRect:(CGRect)rect {  
  2.     [[UIColor blueColor] setFill];  
  3.     [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];  
  4. }  
¸´ÖÆ´úÂë



22. ÄãΪʲô֪µÀÕâô¶àÆæ¹ÖµÄ»¨ÕУ¿

È¥Stack OverflowË¢ÎÊÌâ°¡£¬ÉÙÄ꣡IOSÅàѵѧԺÈÏΪÄãÓÀÔ¶ÊÇ×î°ôµÄ



±¾ÎİæÈ¨¹éÀÖÓã²¥¿ÍIOSÅàѵѧԺËùÓУ¬»¶Ó­×ªÔØ£¬×ªÔØÇë×¢Ã÷×÷Õß³ö´¦¡£Ð»Ð»£¡
×÷ÕߣºÀÖÓã²¥¿ÍIOSÅàѵѧԺ
Ê×·¢£ºhttp://www.itcast.cn/ios/
0 ·ÖÏíµ½£º
ºÍÎÒÃÇÔÚÏß½»Ì¸£¡
¡¾ÍøÕ¾µØÍ¼¡¿¡¾sitemap¡¿