成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

不可不知的:iOS開發的22個詭異技巧

移動開發 iOS 開發工具
結合自身的實踐開發經驗總結出了22個iOS開發的小技巧,以非常歡樂的語調輕松解決開發過程中所遇到的各種苦逼難題,光讀著便已忍俊不禁。

結合自身的實踐開發經驗總結出了22個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<UIGestureRecognizerDelegate>)self; 

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

  1. self.automaticallyAdjustsScrollViewInsets = NO; 

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

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

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

如圖:

這個神器叫做:KMCGeigerCounter ,快去GitHub上搬運吧。

6. 怎么在不新建一個Cell的情況下調整separaLine的位置?

  1. _myTableView.separatorInset = UIEdgeInsetsMake(010000); 

7. 怎么點擊self.view就讓鍵盤收起,需要添加一個tapGestures么?

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

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. 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. 拉伸圖片的時候怎么才能讓圖片不變形?

方法一:

  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. [[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,重寫這個方法:

  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刷問題啊,少年!

責任編輯:chenqingxiang 來源: 博客園
相關推薦

2021-08-12 16:02:22

Jupyter NotPython命令

2020-06-23 17:30:44

前端Sublime

2023-10-17 18:03:30

Code更改函數

2023-09-25 12:07:43

VS Code開發

2023-10-10 18:07:34

VS Code開發

2024-03-21 08:57:39

語言軟件開發

2010-06-11 14:46:38

可路由協議

2023-06-12 00:38:55

開源Java庫工具

2020-11-30 13:12:04

Linux文本命令

2015-01-15 09:34:28

2023-06-15 11:01:43

Java工具開源

2023-09-20 09:00:00

2023-11-13 14:19:57

Golang編程語言

2023-09-22 12:14:33

2015-05-25 19:13:13

KPI開發者

2024-09-23 21:05:45

2023-06-26 14:11:06

SQLC++語言

2023-06-08 13:10:04

2010-10-27 10:39:44

求職

2014-06-20 14:35:48

浪潮數據
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国内自拍视频在线观看 | 日本天堂一区二区 | 午夜资源 | 99精品国产一区二区三区 | 亚洲人精品午夜 | 日韩欧美国产一区二区 | 色视频在线播放 | 中文字幕一区二区三区在线视频 | 国产乱码高清区二区三区在线 | 天堂亚洲网| 日日夜夜草 | 国产精品久久久久久久7777 | 亚洲一区二区电影在线观看 | 成人激情视频 | 日韩中文一区 | 99久久婷婷国产综合精品电影 | 午夜精品久久久久久久久久久久久 | 日韩中文一区二区三区 | 欧美久久久网站 | 992tv人人草 久久精品超碰 | 91在线 | 日本久久黄色 | 一本岛道一二三不卡区 | 亚洲视频欧美视频 | 亚洲欧美一区二区在线观看 | 欧美一区二区 | 国产一级在线 | 日韩欧美一区二区三区在线播放 | 亚洲高清在线免费观看 | 成人免费观看男女羞羞视频 | 成人网在线 | 天天操天天射综合 | h视频免费在线观看 | 国产丝袜一区二区三区免费视频 | 国产成人免费视频 | 精品伊人久久 | 欧美在线一区二区三区 | 久久99视频精品 | 亚洲国产二区 | 成人国产精品久久 | 亚洲精品久久久久久久久久久 |