草庐IT

ios - 设置导航栏按钮的目标

我正在尝试向我的导航Controller导航栏添加左按钮,但出现错误:Cannotconvertvalueoftype'NSObject->()->LocationViewController'toexpectedargumenttype'AnyObject?'.我查看了其他SO问题,他们大部分都说要设置这样的导航栏按钮。非常感谢任何帮助。varleftAddBarButtonItem:UIBarButtonItem=UIBarButtonItem(title:"Cancel",style:.Plain,target:self,action:#selector(cancelButton

ios - 如何从选项卡栏 Controller 访问 subview Controller

这似乎是个愚蠢的问题,但我不太明白:我的Storyboard看起来像:TabBarController->NavigationController->TableViewController1->TableViewController2.此代码位于TabBarController中,我正在尝试访问TableViewController2按照我的理解,这让我得到了NavigationControllerlettempNavVC=self.viewControllers?[0]as!UINavigationController这应该让我得到TableViewController2,因为我认为

ios - 推送搜索结果后,顶部布局指南移动到导航栏下方

这个已经好几天了。我认为说明我的问题的最简单方法是使用这个10秒的gif。描述如您所见,当您在推送到搜索结果后返回时,分段的顶部栏会在您返回时消失,但是当我切换到标题中带有“Tise”的选项卡并返回时,它会重置并起作用如以下屏幕截图所示,我的问题是顶部布局指南在导航栏下方偏移,这使得分段栏隐藏在其下方。代码我的搜索Controller是一个非常正常的实现。/*Searchcontroller*/letexploreSearchController=StandaloneExploreSearchResultController.initFromStoryboard(type:.top)s

ios - 按下导航栏的内置后退按钮时弹出到 Root View Controller

每当在我的顶ViewController上按下后退按钮时,我都想返回到不是前一个ViewController的特定ViewController。我希望有一种方法可以以某种方式覆盖后退按钮的功能。编辑:我让这个工作:self.navigationController?.popToRootViewController(animated:true)唯一的问题是它在动画时将中间ViewController显示为它的根。 最佳答案 阅读您编辑过的问题,看来您正在寻找的是弹出回到导航堆栈中的RootViewController,而动画不会显示其

ios - 如何将数据从 View Controller 传递到选项卡栏 Controller 的第一个选项卡

我想将图像和新闻从ViewController传递到连接的标签栏Controller的第一个选项卡。NewsViewController的第一个选项卡不显示新闻标题和图像。didSelectRowAtindexPath方法如下。functableView(_tableView:UITableView,didSelectRowAtindexPath:IndexPath){letstorybaord=UIStoryboard(name:"Main",bundle:nil)lettabBar=storybaord.instantiateViewController(withIdentifie

swift - 如何在远离系统栏的地方打开一个NSPopover?

我正在打开一个NSPopover,状态栏中有一个图标的Action。myPopover.show(relativeTo:button.bounds,of:button,preferredEdge:NSRectEdge.minY)除了弹出窗口和系统栏的距离为零外,这工作正常:我想获得与Dropbox应用程序相同的结果,它在离系统栏很近的地方呈现弹出窗口:我试过使用button.bounds.offsetBy(dx:0.0,dy:20.0)这不会影响popover和button.bounds.offsetBy(dx:0.0,dy:-20.0)将弹出窗口置于系统栏上方:那么如何将NSPopo

ios - 如何在导航栏中使用搜索栏实现分段控制?

我想知道是否可以在同一个导航栏中添加一个UISegmentedControl和UISearchBar?我试图最小化我的UISearchBar,但它不起作用:lazyvarsearchBar=UISearchBar(frame:CGRect.zero)overridefuncviewDidLoad(){tableView.delegate=selftableView.dataSource=selfsearchBar.searchBarStyle=.minimalnavigationItem.titleView=searchBar}我知道像AppleMusic这样的应用已经做到了这一点:该

ios - iOS 10 和 iOS 11 之间不同的导航栏背景颜色

我将我的导航栏颜色设置为#479F46,在iOS10中它显示为#5DA15D但在iOS11中它显示为#4D9D4E我做错了什么?如何解决?我在应用委托(delegate)中使用的代码funcsetupNavigationController(){UINavigationBar.appearance().barTintColor=UIColor.colorWithHexString(hexStr:"479F46")UINavigationBar.appearance().tintColor=UIColor.whitelettextAttributes=[NSAttributedStrin

swift - 导航栏后退按钮无文本的代码

我有以下代码让我的导航栏中的后退按钮保持无文本状态:self.navigationController?.navigationBar.tintColor=UIColor.whiteColor()letbackItem=UIBarButtonItem(title:"",style:.Bordered,target:nil,action:nil)navigationItem.backBarButtonItem=backItem这一直有效,直到我更新了xCode。现在我收到此错误消息:'Bordered'wasdeprecatediniOSversion8.0:UseUIBarButtonI

ios - 在弹出窗口上显示导航栏

我正在尝试模仿iOS上日历应用程序的设计,现在几个小时我都遇到了同样的问题。我试图以两种不同的方式显示ViewController,具体取决于应用程序运行的设备。如果用户使用的是iPhone,则ViewController将使用推送转场显示。这很好用。如果用户使用的是iPad,则ViewController应该显示为弹出窗口。这也有效,除了我似乎无法在显示为弹出窗口时显示导航栏这一事实。这是一张描述我希望它看起来如何的图片: 最佳答案 使用您的ViewController作为rootViewController创建一个UINavig