µ¼¶Á£ºTableView²»ÏÔʾûÄÚÈݵÄCellÔõô°ì£¿¼üÅÌʼþдµÃºÃ·³Ô꣬¶¼Ïëˤ¼üÅÌÁËÔõô°ì£¿AppÀϲ»Á÷³©ÄijöÎÊÌâÁË£¿CoreDataÓï·¨ÓÖ³ôÓÖ³¤Ôõô°ì£¿ÀÉìͼƬÔõô²ÅÄܲ»±äÐΣ¿ÈÃÎÒÃÇÒ»Æð»¶ÀÖµØÔÚIOSÅàѵѧԺÖÐѧϰһÏÂiOS¿ª·¢µÄ¸÷ÖÖС¼¼Çɰɡ£
1. TableView²»ÏÔʾûÄÚÈݵÄCellÔõô°ì£¿
ÀàËÆÓÚͼ1£¬ÎÒ²»ÏëÈÃÏÂÃæµÄÄÇЩ¿ÕÏÔʾ¡£ºÜ¼òµ¥£¬Ìí¼Ó“self.tableView.tableFooterView = [[UIView alloc] init];”ÊÔ¹ý¶¼ËµºÃ£¬¼ÓÍêÕâ¾äÖ®ºó¾Í±ä³ÉÁËͼ2µÄÑù×Ó¡£
|

2. ×Ô¶¨ÒåÁËleftBarbuttonItem×󻬷µ»ØÊÖÊÆÊ§Ð§ÁËÔõô°ì£¿
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
- initWithImage:img
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onBack:)];
- self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIG
¸´ÖÆ´úÂë
3. ScrollViewĪÃûÆäÃî²»ÄÜÔÚviewController»®µ½¶¥Ôõô°ì£¿
- self.automaticallyAdjustsScrollViewInsets = NO;
¸´ÖÆ´úÂë
4. ¼üÅÌʼþдµÃºÃ·³Ô꣬¶¼Ïëˤ¼üÅÌÁËÔõô°ì£¿
- Âò¸ö½áʵµÄ¼üÅÌ£»
- ʹÓÃIQKeyboardManager£¨GitHubÉÏ¿ÉËÑË÷£©£¬ÓÃÍêÖ®ºóÑüÒ²²»ÌÛÁË£¬ÍÈÒ²²»ËáÁË¡£
5. ΪʲôÎÒµÄAppÀÏÊDz»Á÷³©£¬µ½µ×ÄÄÀï³öÁËÎÊÌ⣿
Èçͼ£º

Õâ¸öÉñÆ÷½Ð×ö£ºKMCGeigerCounter £¬¿ìÈ¥GitHubÉϰáÔ˰ɡ£
6. ÔõôÔÚ²»Ð½¨Ò»¸öCellµÄÇé¿öϵ÷ÕûseparaLineµÄλÖã¿
- _myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);
¸´ÖÆ´úÂë
7. Ôõôµã»÷self.view¾ÍÈüüÅÌÊÕÆð£¬ÐèÒªÌí¼ÓÒ»¸ötapGesturesô£¿
- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
¸´ÖÆ´úÂë
8. Ôõô¸øÃ¿¸öViewControllerÉ趨ĬÈϵı³¾°Í¼Æ¬£¿
ʹÓûùÀà°¡£¬ÉÙÄê¡£
9. ÏëÔÚ´úÂëÀï¸ÄÔÚxibÀïÌí¼ÓµÄlayoutAttributes£¬µ«¸ÃÔõôÓôúÂëÕÒ£¿
ÏñÀButtonÒ»ÑùµØÀÄãµÄÔ¼Êø£¬nslayoutattributeÒ²ÊÇ¿ÉÒÔÀÏߵġ£
10. ÔõôÏñSafariÒ»Ñù»¬¶¯µÄʱºòÒþ²Ønavigationbar£¿
- navigationController.hidesBarsOnSwipe = Yes
¸´ÖÆ´úÂë
11. µ¼º½Ìõ·µ»Ø¼ü´øµÄtitleÌ«ÌÖÑáÁË£¬ÔõôÈÃËüÏûʧ£¿
- [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
- forBarMetrics:UIBarMetricsDefault];
¸´ÖÆ´úÂë
12. CoreDataÓÃÆðÀ´ºÃ·³£¬Óï·¨ÓÖ³ôÓÖ³¤Ôõô°ì£¿
MagicRecord
13. CollectionViewÔõôʵÏÖtableviewÄÇÖÖÐüÍ£µÄheader£¿
CSStickyHeaderFlowLayout
14. Äܲ»ÄÜÖ»ÓÃÒ»¸öpanÊÖÊÆÀ´´úÌæUISwipegestureµÄ¸÷¸ö·½Ïò£¿
- - (void)pan:(UIPanGestureRecognizer *)sender
- {
- typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) {
- UIPanGestureRecognizerDirectionUndefined,
- UIPanGestureRecognizerDirectionUp,
- UIPanGestureRecognizerDirectionDown,
- UIPanGestureRecognizerDirectionLeft,
- UIPanGestureRecognizerDirectionRight
- };
- static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined;
- switch (sender.state) {
- case UIGestureRecognizerStateBegan: {
- if (direction == UIPanGestureRecognizerDirectionUndefined) {
- CGPoint velocity = [sender velocityInView:recognizer.view];
- BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x);
- if (isVerticalGesture) {
- if (velocity.y > 0) {
- direction = UIPanGestureRecognizerDirectionDown;
- } else {
- direction = UIPanGestureRecognizerDirectionUp;
- }
- }
- else {
- if (velocity.x > 0) {
- direction = UIPanGestureRecognizerDirectionRight;
- } else {
- direction = UIPanGestureRecognizerDirectionLeft;
- }
- }
- }
- break;
- }
- case UIGestureRecognizerStateChanged: {
- switch (direction) {
- case UIPanGestureRecognizerDirectionUp: {
- [self handleUpwardsGesture:sender];
- break;
- }
- case UIPanGestureRecognizerDirectionDown: {
- [self handleDownwardsGesture:sender];
- break;
- }
- case UIPanGestureRecognizerDirectionLeft: {
- [self handleLeftGesture:sender];
- break;
- }
- case UIPanGestureRecognizerDirectionRight: {
- [self handleRightGesture:sender];
- break;
- }
- default: {
- break;
- }
- }
- break;
- }
- case UIGestureRecognizerStateEnded: {
- direction = UIPanGestureRecognizerDirectionUndefined;
- break;
- }
- default:
- break;
- }
- }
¸´ÖÆ´úÂë
15. ÀÉìͼƬµÄʱºòÔõô²ÅÄÜÈÃͼƬ²»±äÐΣ¿
·½·¨Ò»£º
- UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
¸´ÖÆ´úÂë
×¢£ºÓпª·¢ÕßÌáÐÑÕâ¸öÒѾÆúÓã¬ÏÖÔڵķ½·¨½ÐresizableImageWithCapInsets¡£
·½·¨¶þ£¬Èçͼ£º

16. Ôõô²¥·ÅGIFµÄʱºòÕâô¿¨£¬ÓÐûÓкõãµÄ¿â£¿
FlipBoard³öÆ·µÄFLAnimatedImageÌ«ÊʺÏÄãÁË¡£
17. Ôõôһ¾ä»°Ìí¼ÓÉÏÀˢУ¿
ʹÓÃSVPullToRefresh¿â£º
- [tableView addPullToRefreshWithActionHandler:^{
- // prepend data to dataSource, insert cells at top of table view
- // call [tableView.pullToRefreshView stopAnimating] when done
- } position:SVPullToRefreshPositionBottom];
¸´ÖÆ´úÂë
18. Ôõô°ÑtableviewÀïCellµÄС¶Ô¹´ÑÕÉ«¸Ä³É±ðµÄÑÕÉ«£¿
- _mTableView.tintColor = [UIColor redColor];
¸´ÖÆ´úÂë

19. ±¾À´ÎÒµÄstatusbarÊÇlightcontentµÄ£¬½á¹ûÓÃUIImagePickerController»áµ¼ÖÂÎÒµÄstatusbarµÄÑùʽ±ä³ÉºÚÉ«£¬Ôõô°ì£¿
- - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
- {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- }
¸´ÖÆ´úÂë
20. Ôõô°ÑÎÒµÄnavigationbarŪ³É͸Ã÷µÄ¶ø²»ÊÇ´øÄ£ºýµÄЧ¹û£¿
- [self.navigationBar setBackgroundImage:[UIImage new]
- forBarMetrics:UIBarMetricsDefault];
- self.navigationBar.shadowImage = [UIImage new];
- self.navigationBar.translucent = YES;
¸´ÖÆ´úÂë
21. Ôõô¸Ä±äuitextfield placeholderµÄÑÕÉ«ºÍλÖã¿
¼Ì³Ðuitextfield£¬ÖØÐ´Õâ¸ö·½·¨£º
- - (void) drawPlaceholderInRect:(CGRect)rect {
- [[UIColor blueColor] setFill];
- [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
- }
¸´ÖÆ´úÂë
22. ÄãΪʲô֪µÀÕâô¶àÆæ¹ÖµÄ»¨ÕУ¿
È¥Stack OverflowË¢ÎÊÌâ°¡£¬ÉÙÄ꣡IOSÅàѵѧԺÈÏΪÄãÓÀÔ¶ÊÇ×î°ôµÄ
±¾ÎİæÈ¨¹éÀÖÓã²¥¿ÍIOSÅàѵѧԺËùÓУ¬»¶Ó×ªÔØ£¬×ªÔØÇë×¢Ã÷×÷Õß³ö´¦¡£Ð»Ð»£¡
×÷ÕߣºÀÖÓã²¥¿ÍIOSÅàѵѧԺ
Ê×·¢£ºhttp://www.itcast.cn/ios/