我有一个简单的视图应用程序,只有一个主视图.
当应用程序进入后台状态时,我正在尝试在视图内的标签中显示更新的时间值.
场景是:
1 - 单视图应用程序项目
2 - 只有一个带有一个Label的View(ViewController)来显示日期
3 - 在AppDelegate中:applicationWillEnterForeground获取当前时间
func applicationWillEnterForegound(application: UIAPplication){
var date:String = GetDate()
--> update View Label with date here
}
Run Code Online (Sandbox Code Playgroud)
4 - 在ViewController上显示当前时间
我正在尝试代理,但问题是视图是应用程序和方法中的最后一个可见元素,因为viewDidLoad,viewWillAppear被调用一次.
我想要一个没有圆角但没有箭头的弹出窗口.
我已经完成了以下代码,但它不起作用:
//SerachPopViewController.swift
//MARK: InitCoder
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//popover settings
//popoverPresentationController!.permittedArrowDirections = .Any
modalPresentationStyle = .Popover
popoverPresentationController!.delegate = self
//permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.preferredContentSize = CGSize(width:340,height:380)
}
Run Code Online (Sandbox Code Playgroud)
//QueryTableViewController.swift
@IBAction func searchFilter(sender: AnyObject) {
let searchPopController = storyboard!.instantiateViewControllerWithIdentifier("SerachPopViewController") as! SerachPopViewController
searchPopController.serachPopDelegate = self
searchPopController.modalPresentationStyle = .Popover
searchPopController.preferredContentSize = CGSize(width:340,height:380)
let popoverPresentationController = searchPopController.popoverPresentationController
popoverPresentationController!.sourceView = self.view;
popoverPresentationController!.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0)
popoverPresentationController!.permittedArrowDirections = UIPopoverArrowDirection();
self.presentViewController(searchPopController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
我可以用箭头和圆形箭头显示弹出窗口视图.
请帮我实现: