小编SHN*_*SHN的帖子

Swift - 当应用程序进入后台状态时,从AppDelegate更新RootViewController中的值

我有一个简单的视图应用程序,只有一个主视图.

当应用程序进入后台状态时,我正在尝试在视图内的标签中显示更新的时间值.

场景是:

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被调用一次.

iphone uiviewcontroller ios swift

8
推荐指数
1
解决办法
4665
查看次数

popoverpresentviewcontroller与矩形角和没有箭头

我想要一个没有圆角但没有箭头的弹出窗口.

我已经完成了以下代码,但它不起作用:

//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)

我可以用箭头和圆形箭头显示弹出窗口视图.

请帮我实现:

  • 弹出视图与矩形角
  • 没有方向箭头的弹出视图

iphone uipopovercontroller ios swift

7
推荐指数
3
解决办法
6656
查看次数