自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

不可不知的:iOS開發(fā)的22個(gè)詭異技巧

移動開發(fā) iOS 開發(fā)工具
結(jié)合自身的實(shí)踐開發(fā)經(jīng)驗(yàn)總結(jié)出了22個(gè)iOS開發(fā)的小技巧,以非常歡樂的語調(diào)輕松解決開發(fā)過程中所遇到的各種苦逼難題,光讀著便已忍俊不禁。

結(jié)合自身的實(shí)踐開發(fā)經(jīng)驗(yàn)總結(jié)出了22個(gè)iOS開發(fā)的小技巧,以非常歡樂的語調(diào)輕松解決開發(fā)過程中所遇到的各種苦逼難題,光讀著便已忍俊不禁。

1. TableView不顯示沒內(nèi)容的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<UIGestureRecognizerDelegate>)self; 

3. ScrollView莫名其妙不能在viewController劃到頂怎么辦?

  1. self.automaticallyAdjustsScrollViewInsets = NO; 

4. 鍵盤事件寫得好煩躁,都想摔鍵盤了怎么辦?

買個(gè)結(jié)實(shí)的鍵盤;
使用IQKeyboardManager(GitHub上可搜索),用完之后腰也不疼了,腿也不酸了。

5. 為什么我的App老是不流暢,到底哪里出了問題?

如圖:

這個(gè)神器叫做:KMCGeigerCounter ,快去GitHub上搬運(yùn)吧。

6. 怎么在不新建一個(gè)Cell的情況下調(diào)整separaLine的位置?

  1. _myTableView.separatorInset = UIEdgeInsetsMake(010000); 

7. 怎么點(diǎn)擊self.view就讓鍵盤收起,需要添加一個(gè)tapGestures么?

  1. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
  2. [self.view endEditing:YES]; 

8. 怎么給每個(gè)ViewController設(shè)定默認(rèn)的背景圖片?

使用基類啊,少年。

9. 想在代碼里改在xib里添加的layoutAttributes,但該怎么用代碼找?

像拉Button一樣地拉你的約束,nslayoutattribute也是可以拉線的。

10. 怎么像Safari一樣滑動的時(shí)候隱藏navigationbar?

  1. navigationController.hidesBarsOnSwipe = Yes 

11. 導(dǎo)航條返回鍵帶的title太討厭了,怎么讓它消失?

  1. [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60
  2. forBarMetrics:UIBarMetricsDefault]; 

12. CoreData用起來好煩,語法又臭又長怎么辦?

  MagicRecord

13. CollectionView怎么實(shí)現(xiàn)tableview那種懸停的header?

  CSStickyHeaderFlowLayout

14. 能不能只用一個(gè)pan手勢來代替UISwipegesture的各個(gè)方向?

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

15. 拉伸圖片的時(shí)候怎么才能讓圖片不變形?

方法一:

  1. UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10]; 

注:有開發(fā)者提醒這個(gè)已經(jīng)棄用,現(xiàn)在的方法叫resizableImageWithCapInsets。

方法二,如圖:

16. 怎么播放GIF的時(shí)候這么卡,有沒有好點(diǎn)的庫?

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的,結(jié)果用UIImagePickerController會導(dǎo)致我的statusbar的樣式變成黑色,怎么辦?

  1. - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
  2. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 

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,重寫這個(gè)方法:

  1. - (void) drawPlaceholderInRect:(CGRect)rect { 
  2. [[UIColor blueColor] setFill]; 
  3. [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment]; 

22. 你為什么知道這么多奇怪的花招?

去Stack Overflow刷問題啊,少年!

責(zé)任編輯:chenqingxiang 來源: 博客園
相關(guān)推薦

2020-06-23 17:30:44

前端Sublime

2021-08-12 16:02:22

Jupyter NotPython命令

2023-10-17 18:03:30

Code更改函數(shù)

2023-10-10 18:07:34

VS Code開發(fā)

2023-09-25 12:07:43

VS Code開發(fā)

2010-06-11 14:46:38

可路由協(xié)議

2024-03-21 08:57:39

語言軟件開發(fā)

2023-06-12 00:38:55

開源Java庫工具

2023-09-20 09:00:00

2023-09-22 12:14:33

2023-11-13 14:19:57

Golang編程語言

2023-06-15 11:01:43

Java工具開源

2020-11-30 13:12:04

Linux文本命令

2015-01-15 09:34:28

2023-06-08 13:10:04

2015-07-28 16:48:04

云計(jì)算性能測試云服務(wù)

2015-05-25 19:13:13

KPI開發(fā)者

2023-06-26 14:11:06

SQLC++語言

2024-09-23 21:05:45

2025-01-03 17:10:54

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號