Popover icon indicating copy to clipboard operation
Popover copied to clipboard

Support for Custom Views

Open kuyazee opened this issue 8 years ago • 4 comments

I hope you add this soon. using custom Xib's

kuyazee avatar Aug 04 '16 09:08 kuyazee

It does support this. I am currently using custom views.

From the sample in the docs:

let startPoint = CGPoint(x: self.view.frame.width - 60, y: 55)
let aView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 180))
let popover = Popover()
popover.show(aView, point: startPoint)

Replace

let aView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 180))

with

let aView = NSBundle.mainBundle().loadNibNamed("SomeXib", owner: self, options: nil).first as? SomeXibType

ems305 avatar Aug 04 '16 17:08 ems305

I think it's probably cause I'm using Swift 2.2. When I use custom views and a normal TableView nothing shows up on screen and the application freezes. But with a normal UIView like your example a blank view shows like it should.

Here's My Code btw

@IBAction func userTypeClicked(sender: AnyObject) {
    let width = self.view.frame.width - 20
    let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: width, height: 120))
    tableView.delegate = self
    tableView.dataSource = self
    tableView.allowsMultipleSelection = true
    tableView.scrollEnabled = false
    let options = [.Type(.Up),
                   .AnimationIn(0.3)] as [PopoverOption]
    let aView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: 120))
    let popover = Popover(options: options)
    popover.show(tableView, point: CGPoint(x: 160, y: 315))
    //popover.show(aView, point: CGPoint(x: 160, y: 315))
}

The UIView one (the commented one) works while the other one doesn't

here's my delegates and datasources

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 40
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cellIdentifierString = "TextCheckboxTableViewCell"
    var cell: TextCheckboxTableViewCell! = tableView.dequeueReusableCellWithIdentifier(cellIdentifierString) as? TextCheckboxTableViewCell
    if cell == nil{
        let objects: NSArray = NSBundle.mainBundle().loadNibNamed(cellIdentifierString, owner: self, options: nil)
        cell = objects.objectAtIndex(0) as! TextCheckboxTableViewCell
    }
    cell.selectionStyle = .None
    cell.lblContent.text = userTypes[indexPath.row]
    return cell
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return userTypes.count
}

kuyazee avatar Aug 08 '16 10:08 kuyazee

I think this issue is to your help. https://github.com/corin8823/Popover/issues/14 You should retain tableView as property

corin8823 avatar Aug 09 '16 06:08 corin8823

I think I'm giving up on this haha. I've tried a lot of stuff and nothing really works.

    let aView = NSBundle.mainBundle().loadNibNamed("SignupOptions", owner: self, options: nil).first as? SignupOptions
    let popover = Popover(options: [.Type(.Up)] as [PopoverOption])
    //aView!.frame = CGRect(x: 0, y: 0, width: 500, height: 500)
    popover.show(aView!, fromView: sender as! UIView, inView: UIApplication.sharedApplication().keyWindow!)

or

   popover.show(aView!, point: CGPoint(x: 0, y: 0))

Even that doesn't seem to work. life is weird hahaha

screen shot 2016-08-09 at 3 19 13 pm

screen shot 2016-08-09 at 3 19 00 pm

kuyazee avatar Aug 09 '16 07:08 kuyazee