我在TableView中有CollectionView。一切都好,但是。当我想将我的单元格导航到另一个viewController时,我遇到了错误
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let bookView: BookSingleController = storyboard.instantiateViewControllerWithIdentifier("BookSingle") as! BookSingleController
self.navigationController?.pushViewController(bookView, animated: true)
bookView.bookID = "\(self.books[indexPath.row].id)"
print(self.books[indexPath.row].id)
}
Xcode show me self.NavigationController?.PushViewController(bookView,Animated:true)行出现错误。这是错误说明:
Value of 'RelatedBookTableViewCell' has no member 'navigationController'
RelatedBookTableViewCell是我的自定义单元格类:
class RelatedBookTableViewCell: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout
我的问题在哪里?
谢了。
尝试从应用程序中的根控制器推入VC。
UIApplication.sharedApplication().keyWindow?.rootViewController
null
其中,您将来自collectionView委托方法
斯威夫特
自定义协议
在tableViewController中
class tableViewController: UITableViewController, DisplayBookDelegate {
...
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.delegate = self
return UITableViewCell()
}
func displayBook(let bookId) {
self.navigationController?.pushViewController(bookView, animated: true)
}
}
在单元格中
var delegate: DisplayBookDelegate?
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
self.delegate.displayBook("1")
}
objc:
swift
使用下面的代码,您可以获得顶部的视图控制器,并使用该视图控制器,您可以执行推送操作
let objViewController = UIApplication.topViewController()!
使用此扩展名
extension UIApplication {
class func topViewController(base: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return topViewController(nav.visibleViewController)
}
if let tab = base as? UITabBarController {
if let selected = tab.selectedViewController {
return topViewController(selected)
}
}
if let presented = base?.presentedViewController {
return topViewController(presented)
}
return base
}
}
修改聊天页面导航栏背景色、导航栏上增加自定义按钮、修改导航栏上图标按钮颜色等 /** 聊天窗口导航栏 @param navigationBar 导航栏 */ - (void)ntalker_navigationBar:(UIView *)navigationBar { navigationBar.backgroundColor = [UIColor redColor];//修改导航栏背景色 }
Navbar 自定义导航栏 平台差异说明 App H5 微信小程序 支付宝小程序 百度小程序 头条小程序 QQ小程序 √ √ √ √ √ √ √ 基本使用 默认情况下,该组件只有向左的箭头,点击可以返回上一页,如果您想将自定义导航栏用在tabbar(不存在要返回的逻辑)页面,应该将is-back设置为false, 这样会隐藏左边的返回图标区域。 如果想在返回箭头的右边自定义类似"返回"字样,可以将
我将Google sign SDK集成到我的应用程序中。但我不知道如何改变状态栏的颜色和导航栏的颜色。我试图用appdelegate中的[[UIAbbar外观]SetPartInColor]和[[UIApplication sharedApplication]setStatusBarStyle]更改颜色,但什么也没发生。我真的需要你的帮助。谢谢
我正试图将Amplify集成到我的项目中,但我在配置方面遇到了一些问题。后端将S3存储配置发送到我的项目,因此我必须使用接收到的数据配置Amplify。我尝试在测试后配置存储,但失败,出现以下错误: 这是我的代码: 有人能帮我做这个自定义配置吗?谢谢
本文向大家介绍Android自定义顶部导航栏控件实例代码,包括了Android自定义顶部导航栏控件实例代码的使用技巧和注意事项,需要的朋友参考一下 下面一段代码给大家介绍了android 自定义顶部导航栏控件功能,具体代码如下所示: 总结 以上所述是小编给大家介绍的Android自定义顶部导航栏控件实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家
HTML 如果你需要定制导航栏,可以用 HTML 创建一个导航栏。 注意:文档的链接都要以 #/ 开头。 <!-- index.html --> <body> <nav> <a href="#/">EN</a> <a href="#/zh-cn/">中文</a> </nav> <div id="app"></div> </body> 配置文件 那我们可以通过 Mar