2016-05-13 12 views
5

मैं एक पॉपअप बनाने की कोशिश कर रहा हूं जो एक बटन दबाकर प्रस्तुत किया जाएगा। Google में मिले निर्देशों का पालन करने का प्रयास किया लेकिन मेरा पॉप व्यू एक पूर्ण स्क्रीन में प्रस्तुत होता है और इसकी पृष्ठभूमि काला है।पॉपअप UIViewController

class ViewController: UIViewController, UIPopoverPresentationControllerDelegate { 

    @IBAction func someButtonPressed(sender: UIButton) { 
     let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
     let popupVC = storyboard.instantiateViewControllerWithIdentifier("hello") as! popupViewController 
     popupVC.modalPresentationStyle = .Popover 
     popupVC.preferredContentSize = CGSizeMake(300, 300) 
     let pVC = popupVC.popoverPresentationController 
     pVC?.permittedArrowDirections = .Any 
     pVC?.delegate = self 
     pVC?.sourceView = sender 
     pVC?.sourceRect = CGRect(x: 100, y: 100, width: 1, height: 1) 
     presentViewController(popupVC, animated: true, completion: nil) 
    } 
} 

क्या I'am गलत कर: यहाँ मेरी कोड है?

उत्तर

16

आपके विचार नियंत्रक एक पॉपअप के रूप में दिखाया बनाने के लिए, आप निम्न निर्धारित करना चाहिए:

popupVC.modalPresentationStyle = .OverCurrentContext 
popupVC.modalTransitionStyle = .CrossDissolve 

आप भी अपने दृश्य नियंत्रक की स्थिति डिजाइन चाहिए, आकार उसे एक पॉपअप की तरह लग रहे बनाने के लिए।

यहां मेरा पॉपअप है जो मैंने पहले किया था।

enter image description here