Ver Fonte

add image picker

Jonas Reinsch há 6 anos atrás
pai
commit
8c0f0e3fb4
2 ficheiros alterados com 23 adições e 2 exclusões
  1. 21 2
      deltachat-ios/ChatViewController.swift
  2. 2 0
      deltachat-ios/Info.plist

+ 21 - 2
deltachat-ios/ChatViewController.swift

@@ -123,12 +123,17 @@ class ChatViewController: MessagesViewController {
         // scrollsToBottomOnFirstLayout = true //default false
         scrollsToBottomOnKeybordBeginsEditing = true // default false
         
-        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "ic_keyboard"),
+        /*navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "ic_keyboard"),
                                                             style: .plain,
                                                             target: self,
-                                                            action: #selector(handleKeyboardButton))
+                                                            action: #selector(handleKeyboardButton))*/
+        
+        let photoButton = UIBarButtonItem(barButtonSystemItem: .camera, target: self, action: #selector(didPressPhotoButton))
+        navigationItem.rightBarButtonItem = photoButton
     }
     
+
+    
     @objc func handleKeyboardButton() {
         
         messageInputBar.inputTextView.resignFirstResponder()
@@ -368,6 +373,20 @@ extension ChatViewController: MessagesLayoutDelegate {
         return CGSize(width: messagesCollectionView.bounds.width, height: 10)
     }
     
+    @objc func didPressPhotoButton() {
+        let imagePicker = UIImagePickerController()
+        imagePicker.delegate = self
+        imagePicker.sourceType = .camera
+        imagePicker.cameraDevice = .rear
+        self.present(imagePicker, animated: true, completion: nil)
+        
+
+    }
+    
+}
+
+extension ChatViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
+    
 }
 
 

+ 2 - 0
deltachat-ios/Info.plist

@@ -34,6 +34,8 @@
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
+	<key>NSCameraUsageDescription</key>
+	<string>Please allow access to camera</string>
 	<key>UISupportedInterfaceOrientations~ipad</key>
 	<array>
 		<string>UIInterfaceOrientationPortrait</string>