BaseViewController.mm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // BaseViewController.m
  3. // XMeye_Old
  4. //
  5. // Created by zyj on 15/1/7.
  6. // Copyright (c) 2015年 hzjf. All rights reserved.
  7. //
  8. #import "BaseViewController.h"
  9. #import "SVProgressHUD.h"
  10. #import "FunSDK/FunSDK.h"
  11. class CBaseObjInfo
  12. {
  13. public:
  14. CBaseObjInfo()
  15. {
  16. _pWnd = 0;
  17. _hWnd = 0;
  18. };
  19. virtual ~CBaseObjInfo()
  20. {
  21. FUN_UnRegWnd(_hWnd);
  22. _hWnd = 0;
  23. };
  24. void Init(void *pWnd)
  25. {
  26. _pWnd = pWnd;
  27. _hWnd = FUN_RegWnd(pWnd);
  28. };
  29. UI_HANDLE GetId()
  30. {
  31. return _hWnd;
  32. }
  33. private:
  34. UI_HANDLE _hWnd;
  35. void *_pWnd;
  36. };
  37. @interface BaseViewController ()
  38. {
  39. CBaseObjInfo _info;
  40. }
  41. @end
  42. @implementation BaseViewController
  43. - (BOOL)shouldAutorotate {
  44. return YES;
  45. }
  46. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  47. return interfaceOrientation == UIInterfaceOrientationPortrait;
  48. }
  49. -(NSUInteger)supportedInterfaceOrientations
  50. {
  51. return UIInterfaceOrientationMaskPortrait;
  52. }
  53. - (void)viewDidLoad {
  54. [super viewDidLoad];
  55. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActives) name:UIApplicationWillResignActiveNotification object:nil];
  56. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForegrounds) name:UIApplicationWillEnterForegroundNotification object:nil];
  57. }
  58. - (void)viewDidUnload
  59. {
  60. [super viewDidUnload];
  61. }
  62. -(void)viewWillAppear:(BOOL)animated
  63. {
  64. [super viewWillAppear:animated];
  65. }
  66. -(void)viewWillDisappear:(BOOL)animated
  67. {
  68. [super viewWillDisappear:animated];
  69. }
  70. -(void)applicationWillResignActives {
  71. if ([SVProgressHUD isVisible]) {
  72. [SVProgressHUD dismiss];
  73. }
  74. }
  75. -(void)applicationWillEnterForegrounds
  76. {
  77. }
  78. -(int)MsgHandle {
  79. if (_info.GetId() == 0) {
  80. _info.Init((__bridge void *)self);
  81. }
  82. return _info.GetId();
  83. }
  84. -(void)CloseMsgHandle {
  85. }
  86. -(void)didReceiveMemoryWarning {
  87. [super didReceiveMemoryWarning];
  88. }
  89. -(void)dismis
  90. {
  91. if (self.navigationController) {
  92. [self.navigationController popToRootViewControllerAnimated:NO];
  93. }else{
  94. [self dismissViewControllerAnimated:NO completion:nil];
  95. }
  96. }
  97. -(void)dealloc
  98. {
  99. [[NSNotificationCenter defaultCenter] removeObserver:self];
  100. }
  101. @end