PopoverController for iPhone
来源:互联网 发布:中国移动宽带拨号软件 编辑:程序博客网 时间:2024/06/06 10:43
There is no build-in popup windows or popover controllers for iPhones. Only iPad can use popover controller class.
So i use a third-party controller called FPPopover from github. https://github.com/50pixels/FPPopover
But it is not well-developed. There is a bug in FPPopoverView.m, which leads to the blue label when the arrow is at Up direction and the tint is set to white. It should be:
elseif(self.tint ==FPPopoverWhiteTint)
{
colors[0] = colors[1] = colors[2] =1.0;
colors[4] = colors[5] = colors[6] =1.0;
colors[3] = colors[7] =1.0;
}
And there are no properties for arrow height, rounded radius. Users need to modify them in FPPopoverView.m if they don't want rounded rect.How to combine OC and Swift?
Create a popover-Bridging-Header.h file
#Import "FPPopoverController.h" of the third-party framework
Add the relative path of popover-Bridging-Header.h, which is: popover/popover-Bridging-Header.h
Then you can use it with Swift
How to use it?
Add files (mentioned in the website), then add delegate to your VC
var popoverView: FPPopoverController?
var contentVC =PopupViewController()
popoverView =FPPopoverController(viewController: contentVC)
popoverView!.contentSize =CGSizeMake(160,215)
popoverView!.tint =FPPopoverWhiteTint
popoverView!.arrowDirection =FPPopoverNoArrow
popoverView!.border =false
popoverView!.setShadowsHidden(true)
popoverView!.delegate =self
popoverView!.presentPopoverFromPoint(CGPoint(x: 0, y: _naviHeight))
func popoverControllerDidDismissPopover(popoverController:FPPopoverController!) {}
class PopupViewController:UIViewController,UIPickerViewDataSource,UIPickerViewDelegate {
var mthPicker:UIPickerView?
var mthPickerDSyear:[Int] = []
var bgWidth =UIScreen.mainScreen().bounds.size.width
var bgHeight =UIScreen.mainScreen().bounds.size.height
overridefunc viewDidLoad() {
super.viewDidLoad()
for iin 0...99 {
mthPickerDSyear.append(selectedYear! -99 + i)
}
mthPicker =UIPickerView(frame: CGRect(x:0, y: -20, width:150, height: bgHeight))
mthPicker!.dataSource =self
mthPicker!.delegate =self
mthPicker?.backgroundColor =UIColor.whiteColor()
mthPicker!.selectRow(mthPickerDSyear.count - 1, inComponent: 0, animated:false)
mthPicker!.selectRow(selectedMonth! -1, inComponent: 1, animated:false)
self.view.addSubview(mthPicker!)
}
//UIPickerView
func numberOfComponentsInPickerView(pickerView:UIPickerView) -> Int {
return2
}
func pickerView(pickerView:UIPickerView, numberOfRowsInComponent component:Int) -> Int {
if (component ==0){
returnmthPickerDSyear.count
}else{
return12
}
}
func pickerView(pickerView:UIPickerView, titleForRow row: Int, forComponent component: Int) ->String! {
if (component ==0){
return"\(mthPickerDSyear[row])"
}else{
return"\(row +1)"
}
}
func pickerView(pickerView:UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if (component ==0){
selectedYear =mthPickerDSyear[row]
}else{
selectedMonth = row +1
}
}
overridefunc didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
- PopoverController for iPhone
- popoverController
- iPhone For Dummies (For Dummies
- iPhone For Dummies
- iphone tutorial for programmers
- iPhone Tabs for Android!
- Unique Identifier for Iphone
- JSON Framework for iPhone
- Build libicu for iphone
- Building OpenCV for iPhone
- Javascript Effect For iPhone
- demo for iphone
- MultiMedia APIs for iPhone
- Linphone for iphone 编译
- Building FFmpeg for iPhone
- web扣扣 for iphone
- demo for iphone
- Linphone for iphone 编译
- Training:Hash及应用
- 反射的应用
- javascript基础学习之-事件冒泡
- 通过id查询用户,但是只返回指定的字段
- POJ 3469 Dual Core CPU 最小割
- PopoverController for iPhone
- 第十四周项目3-OOP版电子词典
- uva 264 Count on Cantor
- TCP/IP协议族-----6、IP分组的交付和转发
- 测试数据真假难辨-IT精英自我思考
- CentOS安装zip unzip命令
- Android EditText控件切换可编辑状态
- Mysql连接池解决并发问题
- JavaScript中的跨域学习