Skip to content

Commit

Permalink
swift
Browse files Browse the repository at this point in the history
  • Loading branch information
mehaksmansoori committed Jan 28, 2024
1 parent 5f3ab84 commit 1167714
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"liveServer.settings.port": 5501
"liveServer.settings.port": 5502
}
26 changes: 26 additions & 0 deletions ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import UIKit

class MainViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

// Connect this to your "Add Story" button in Interface Builder
@IBAction func addStoryButtonTapped(_ sender: UIButton) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera // or .photoLibrary if you prefer
present(imagePicker, animated: true, completion: nil)
}

// MARK: - UIImagePickerControllerDelegate

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[.originalImage] as? UIImage {
// Handle the selected image here, you can save it, process it, or upload it
// You might want to navigate the user to another screen for editing or adding captions
}
picker.dismiss(animated: true, completion: nil)
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
}

0 comments on commit 1167714

Please sign in to comment.