Open kuyazee opened 8 years ago
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
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
}
I think this issue is to your help. https://github.com/corin8823/Popover/issues/14 You should retain tableView as property
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
I hope you add this soon. using custom Xib's