我最近将我的应用程序从iOS 8.3更新到iOS 9.在使用代码修复各种错误后,我设法编译应用程序并运行它,当我注意到以下问题.
当我执行segue点击时,例如,UIButton,加载了segue的视图会出现一个模态视图的动画(从底部滑动直到它到达顶部),但在故事板中,segue是Show (e.g. Push).此外,导航控制器的后退按钮不再出现.
控制台在执行segue时打印出来:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UISearchController: 0x7ffde14866b0>)
这个问题似乎只出现在一个视图中,当加载其他视图时,我试图将其他视图设置为初始视图控制器并且所有视图都有效.
我收到以下错误.
尝试在取消分配时加载视图控制器的视图是不允许的,并且可能导致未定义的行为()
尝试了以下解决方案,但对我不起作用尝试在取消分配时加载视图控制器的视图... UISearchController
该链接提供了一个演示项目.
代码如下所示,可以从短下载的时间.
import UIKit
class DetailViewController: UIViewController,UITableViewDataSource,UITableViewDelegate,UISearchResultsUpdating,UISearchBarDelegate {
@IBOutlet weak var basicTable: UITableView!
var tblSearchController:UISearchController!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tblSearchController = UISearchController(searchResultsController: nil)
self.basicTable.tableHeaderView=self.tblSearchController.searchBar
// self.tblSearchController.edgesForExtendedLayout = (UIRectEdge.Top )
// self.tblSearchController.extendedLayoutIncludesOpaqueBars = true
self.tblSearchController.searchResultsUpdater = self
self.tblSearchController.searchBar.delegate = self
self.tblSearchController.searchBar.sizeToFit()
// self.tblSearchController.searchBar.frame=CGRectMake(0, 0, self.basicTable.frame.size.width, 44.0)
self.tblSearchController.hidesNavigationBarDuringPresentation=true
self.tblSearchController.dimsBackgroundDuringPresentation=true
self.definesPresentationContext=true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of …Run Code Online (Sandbox Code Playgroud) 我有根故事板,有一个按钮,推动ViewControllerB.
ViewControllerB有一个排序控制器UISortController.
ViewControllerB有一个"后退"方法,由根导航控制器控制.
我收到以下警告:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UISearchController: 0x7ff10258ba60>)
我使用Apple的示例(需要会员资格)来添加新的UISearchController.
有人遇到过这个吗?我该如何解决?
轻触a时UISearchBar,取消按钮滑入,TextField位于上方以容纳按钮.我将这称为取消按钮动画.
在我的应用程序中,当用户点击搜索按钮时,带有a UISearchController和UITableView淡入的视图.我希望视图淡入,取消按钮动画已经完成.与iOS音乐应用类似.我试过这个:
self.myTableView.frame = CGRectMake(0, 20, self.view.bounds.width, self.view.bounds.height - 20)
self.resultSearchController.searchBar.becomeFirstResponder()
UIView.animateWithDuration(0.3, delay: 0.0, options: .CurveLinear, animations: {
self.myTableView.alpha = CGFloat(1.0)
}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
当我将searchBar第一响应者关闭屏幕时,不应该完成取消按钮动画完成吗?它没有.
现在,取消按钮动画在屏幕上发生,然后视图(TableView)淡入.如何在视图的alpha为0时进行取消按钮动画?