STBaseViewC.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // STBaseViewC.m
  3. // BuguLive
  4. //
  5. // Created by 岳克奎 on 17/4/17.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "STBaseViewC.h"
  9. @interface STBaseViewC ()
  10. @end
  11. @implementation STBaseViewC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. // Do any additional setup after loading the view.
  15. }
  16. - (void)didReceiveMemoryWarning {
  17. [super didReceiveMemoryWarning];
  18. // Dispose of any resources that can be recreated.
  19. }
  20. #pragma *************************** Plublic公有方法****************************
  21. #pragma mark --- newViewC < STBaseViewC *>
  22. /**
  23. * @brief: new ViewC methods
  24. *
  25. * @attention: 1. base class declaration 2.subclass implementation、
  26. */
  27. +(STBaseViewC *)showSTBaseViewCOnSuperViewC:(UIViewController *)superViewC
  28. andFrameRect:(CGRect)frameRect
  29. andSTViewCTransitionType:(STViewCTransitionType)stViewCTransitionType
  30. andComplete:(void(^)(BOOL finished,STBaseViewC *stBaseViewC))block{
  31. if (stViewCTransitionType == STViewCTransitionOfChild) {
  32. //① superViewC
  33. if (!superViewC) {
  34. if (block) {
  35. block(NO,nil);
  36. }
  37. }
  38. //② remove from superViewC
  39. for (UIViewController *oneViewC in superViewC.childViewControllers) {
  40. if ([oneViewC isKindOfClass:[self class]]) {
  41. [oneViewC removeFromParentViewController];
  42. [oneViewC.view removeFromSuperview];
  43. }
  44. }
  45. }
  46. //③ newViewC
  47. STBaseViewC *newViewC = [[self alloc]initWithNibName:NSStringFromClass([self class])
  48. bundle:nil];
  49. NSLog(@"=======11===== %@",NSStringFromClass([self class]));
  50. //④ add child for superViewC
  51. if (stViewCTransitionType == STViewCTransitionOfChild) {
  52. //ViewC
  53. [newViewC.view setFrame:superViewC.view.frame];
  54. newViewC.view.frame = frameRect;
  55. //child
  56. [superViewC addChildViewController:newViewC];
  57. [superViewC.view addSubview:newViewC.view];
  58. }else{
  59. newViewC.view.frame = frameRect;
  60. }
  61. //⑤ record
  62. newViewC.recordSuperViewC = superViewC;
  63. //⑥ block
  64. if (block) {
  65. block(YES,newViewC);
  66. }
  67. //⑦ return
  68. return newViewC;
  69. }
  70. #pragma mark -----IQKeyboardManager
  71. -(void)viewDidAppear:(BOOL)animated
  72. {
  73. [super viewDidAppear:animated];
  74. if (!_isOpenIQKeyboardManager) {
  75. return;
  76. }
  77. [IQKeyboardManager sharedManager].enable = YES; //YES == Open IQKeyboard
  78. [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
  79. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  80. [IQKeyboardManager sharedManager].keyboardDistanceFromTextField = 100.0f;
  81. }
  82. -(void)viewDidDisappear:(BOOL)animated
  83. {
  84. [super viewDidDisappear:animated];
  85. if (!_isOpenIQKeyboardManager) {
  86. return;
  87. }
  88. [IQKeyboardManager sharedManager].enable = NO;
  89. [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  90. }
  91. #pragma mark ************************ Getter *****************************
  92. -(GlobalVariables *)globalVariables{
  93. if (!_globalVariables) {
  94. _globalVariables = [GlobalVariables sharedInstance];
  95. }
  96. return _globalVariables;
  97. }
  98. @end