Ver código fonte

socket.io on emit

hxb 9 anos atrás
pai
commit
9154abc7ea
3 arquivos alterados com 103 adições e 0 exclusões
  1. 35 0
      MyAlertViewController.swift
  2. 42 0
      XKeyBoard/XKeyBoard.h
  3. 26 0
      XKeyBoard/XKeyBoard.m

+ 35 - 0
MyAlertViewController.swift

@@ -0,0 +1,35 @@
+//
+//  MyAlertViewController.swift
+//  SocketChat
+//
+//  Created by Justine on 16/6/1.
+//  Copyright © 2016年 AppCoda. All rights reserved.
+//
+
+import UIKit
+
+class MyAlertViewController: UIAlertController {
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+
+        // Do any additional setup after loading the view.
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+        // Dispose of any resources that can be recreated.
+    }
+    
+
+    /*
+    // MARK: - Navigation
+
+    // In a storyboard-based application, you will often want to do a little preparation before navigation
+    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+        // Get the new view controller using segue.destinationViewController.
+        // Pass the selected object to the new view controller.
+    }
+    */
+
+}

+ 42 - 0
XKeyBoard/XKeyBoard.h

@@ -0,0 +1,42 @@
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+@class XKeyBoard;
+@protocol KeyBoardDlegate <NSObject>
+
+- (void)keyboardWillShowNotification:(NSNotification *)notification;
+- (void)keyboardWillHideNotification:(NSNotification *)notification;
+
+@end
+@interface XKeyBoard : NSObject
+/**
+ *  注册键盘出现
+ *
+ *  @param target 目标(self)
+ */
++ (void)registerKeyBoardShow:(id)target;
+/**
+ *  注册键盘隐藏
+ *
+ *  @param target 目标(self)
+ */
++ (void)registerKeyBoardHide:(id)target;
+/**
+ *
+ *
+ *  @return 返回键盘,包括高度、宽度
+ */
++ (CGRect)returnKeyBoardWindow:(NSNotification *)notification;
+/**
+ *
+ *
+ *  @return 返回键盘上拉动画持续时间
+ */
++ (double)returnKeyBoardDuration:(NSNotification *)notification;
+/**
+ *  
+ *
+ *  @return 返回键盘上拉,下拉动画曲线
+ */
++ (UIViewAnimationCurve)returnKeyBoardAnimationCurve:(NSNotification *)notification;
+
+@end

+ 26 - 0
XKeyBoard/XKeyBoard.m

@@ -0,0 +1,26 @@
+
+#import "XKeyBoard.h"
+
+@implementation XKeyBoard
++ (void)registerKeyBoardShow:(id)target{
+    [[NSNotificationCenter defaultCenter] addObserver:target selector:@selector(keyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil];
+}
++ (void)registerKeyBoardHide:(id)target{
+    [[NSNotificationCenter defaultCenter] addObserver:target selector:@selector(keyboardWillHideNotification:) name:UIKeyboardWillHideNotification object:nil];
+}
++ (CGRect)returnKeyBoardWindow:(NSNotification *)notification{
+    CGRect keyboardEndFrameWindow;
+    [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardEndFrameWindow];
+    return keyboardEndFrameWindow;
+}
++ (double)returnKeyBoardDuration:(NSNotification *)notification{
+    double keyboardTransitionDuration;
+    [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&keyboardTransitionDuration];
+    return keyboardTransitionDuration;
+}
++ (UIViewAnimationCurve)returnKeyBoardAnimationCurve:(NSNotification *)notification{
+    UIViewAnimationCurve keyboardTransitionAnimationCurve;
+    [[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&keyboardTransitionAnimationCurve];
+    return keyboardTransitionAnimationCurve;
+}
+@end