我在a UINavigationController的第一个标签中有一个加载UITabBarController.我想在右侧添加一个刷新按钮UINavigationItem.我的朦胧理解是,在将其添加到控件层次结构之前,必须在导航控制器上设置标题和按钮等属性.我没有问题将按钮添加到子导航控制器,但我很难知道如何更改根,因为它是从笔尖加载的.
因此,在下面的IB屏幕上(哎呀,没有足够的声誉点,让我试图绘制这个......),我正在尝试为所选项添加一个刷新按钮.
- 文件的所有者
- 急救人员
- App代表
- 窗口
- 标签栏控制器
- 标签栏
- 观察列表视图控制器
- 导航栏
- 查看控制器
- 表视图
- 导航项目
- 标签栏项目
- 另一个List View Controller
- 等等
- 等等
我试图添加按钮navigationController's viewDidLoad,没有任何帮助:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(refresh:)];
}
Run Code Online (Sandbox Code Playgroud)
我还尝试以编程方式将我添加ObservationListViewController到UITabBarController,并在该块中插入按钮,但我的方式已经超出了我的深度.
知道如何在从笔尖加载导航控制器的过程中添加一个按钮吗?
谢谢!
iphone objective-c uinavigationbar uinavigationcontroller uinavigationitem
如何将现有的UIViewController(使用presentModalViewController呈现)添加到UINavigationController?
当用户点击按钮时,需要推送我的详细视图的新副本.(换句话说,pushViewController在UINavigationController中以模态方式显示pushViewController).
最简单的方法来启用此功能?
我UINavigationController在里面使用UITabBarController,我的导航控制器中的一个屏幕是一个UIImageView.当我想要全屏显示图像时,我必须隐藏导航栏和标签栏.我可以正确隐藏导航栏但是当我隐藏标签栏时,它会留下50px的空白区域.有什么建议吗?
uinavigationbar uitabbarcontroller uinavigationcontroller uitabbar ios
我在我的only-ios5应用程序中有一个navigationControllerDelegate:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"common-settingsbutton"] style:UIBarButtonItemStylePlain target:nil action:nil];
[viewController.navigationItem setRightBarButtonItem:myButton];
}
Run Code Online (Sandbox Code Playgroud)
它可以工作,但是当一个具有默认动画的推视控制器(即使用"推送segue")时,右边的BallButtonItem淡出和动画中的fadein.
我怎么能避免这个?
UPDATE
我找到的唯一解决方法是:使用在png中绘制的相同UIBarButtonItem
创建UINavigationBar背景(在相同位置,相同颜色)并根据我需要的按钮正确设置背景.然后,当然,添加您的UIBarButtonItems.
iphone objective-c uinavigationcontroller uibarbuttonitem ios5
我的弹出窗口显示有问题.之后initWithContentViewController:,presentPopoverFromBarButtonItem:permittedArrowDirections:animated:它切断导航栏的角落.我应该怎么解决?谢谢.

这是我正在使用的代码
NavContr *nav = [NavContr new];
nav.navigationBar.backgroundColor = [UIColor redColor];
UIPopoverController *tempPop = [[UIPopoverController alloc] initWithContentViewController:nav];
[tempPop presentPopoverFromBarButtonItem:mainButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
Run Code Online (Sandbox Code Playgroud)
编辑:我已经解决了这个问题:
+ (void)configure:(UINavigationController *)navController {
UINavigationBar *navigationBar = navController.navigationBar;
UIView *contentView = nil;
for (UIView *view in navController.view.subviews) {
if ([[NSString stringWithFormat:@"%@", [view class]] isEqualToString:@"UILayoutContainerView"])
contentView = view;
}
// setting frame to navigation bar and content view
[navigationBar setFrame:CGRectMake(navigationBar.frame.origin.x, 0, navigationBar.frame.size.width, navigationBar.frame.size.height)];
[contentView setFrame:CGRectMake(contentView.frame.origin.x, 0, contentView.frame.size.width, contentView.frame.size.height + navigationBar.frame.size.height)];
[navController.view bringSubviewToFront:contentView];
for (UIView …Run Code Online (Sandbox Code Playgroud) iphone objective-c uinavigationcontroller uipopovercontroller
我正在尝试在控制器的导航栏中设置后退按钮图像,这是我在viewDidLoad()中的代码:
var backImg: UIImage? = UIImage(named: "back_btn.png")
println(backImg)
if var back_img = backImg {
println("GET IT")
println(back_img)
println(UIControlState.Normal)
println(UIBarMetrics.Default)
self.navigationController.navigationBar.backItem.backBarButtonItem.setBackButtonBackgroundImage(back_img, forState: UIControlState.Normal, barMetrics: UIBarMetrics.Default)
}
Run Code Online (Sandbox Code Playgroud)
我试图把它们放到viewWillLoad,但得到同样的错误
控制台显示错误消息:
<UIImage: 0x7ff37bd85750>
GET IT
<UIImage: 0x7ff37bd85750>
VSC14UIControlState (has 1 child)
(Enum Value)
fatal error: unexpectedly found nil while unwrapping an Optional value
Run Code Online (Sandbox Code Playgroud)
我不知道哪个部分出了问题.看起来像back_img不是零,但我得到错误说它是零
谢谢!
uinavigationbar uinavigationcontroller uinavigationitem ios swift
我有一个应用程序,其中一个标签栏控制器嵌入在导航控制器中.该应用程序有2个选项卡,第一个(搜索)有一个使用UISearchController实现的搜索栏.如果我在搜索时从此选项卡切换到其他选项卡(下载),则在其他选项卡中会发生两件事 -
我使用故事板完成了所有这些.
这是我的SearchViewController
import UIKit
import Alamofire
import SwiftyJSON
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UISearchResultsUpdating, UISearchBarDelegate{
//MARK: Variables
var papers = [Paper]()
var filteredPapers = [Paper]()
let searchController = UISearchController(searchResultsController: nil)
// MARK: Outlets
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet var table: UITableView!
@IBOutlet weak var loadingMessageLabel: UILabel!
@IBOutlet weak var retryButton: UIButton!
//MARK: Actions
@IBAction func retryButton(sender: UIButton) {
self.loadingMessageLabel.hidden = false
self.loadingMessageLabel.text = "While the satellite moves into position..."
self.activityIndicator.hidden = false
self.activityIndicator.startAnimating()
self.retryButton.hidden = …Run Code Online (Sandbox Code Playgroud) uinavigationcontroller ios uisearchcontroller nstabviewcontroller
我正在尝试更改标签栏项目的徽章但没有成功.我明白标签栏控制器负责控制器的标签栏.
但是,标签栏本身中的某些内容可以由视图控制器(例如徽章)管理
在我的代码中我尝试了这个在视图中加载
self.tabBarItem.badgeValue = "3"
Run Code Online (Sandbox Code Playgroud)
但徽章中没有任何内容
然后我试了一下:
self.tabBarController?.tabBarItem.badgeValue = "3"
Run Code Online (Sandbox Code Playgroud)
哪个不起作用,好吧,我知道为什么第二个代码不起作用,它与使用导航控制器而不是导航项更改导航控件的标题相同.但我不知道为什么第一个代码不起作用
这是我的应用程序的hiechy,我在TeamsTableViewController中这样做,这是团队选项卡中的第一个视图控制器
从标题中可以看出,当我尝试UIViewController使用UITableView它并显示LargeTitle时,它会在第一时刻显示,然后隐藏到小的那个.
这很奇怪但是这个bug 只能在4英寸设备上重现.
这种行为似乎是Apple的错误.
我错过了任何其他的变通办法或细微差别?谢谢你的任何建议.
uinavigationbar uiviewcontroller uinavigationcontroller ios ios11
嘿伙计们我已经习惯了largeNavigationBar,直到我刷回根视图控制器并且大导航以令人讨厌的方式获得清晰的颜色.这是代码:
func largeNavigationTitle() {
self.navigationController?.view.backgroundColor = VVUtility.navigationBarColor()
let productTitle = request?.product?.name
self.navigationItem.title = "\(productTitle ?? " ")".localized()
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white, NSAttributedStringKey.font : VVUtility.normalFontWithPlusSize(increaseSize: -2.0)]
if #available(iOS 11.0, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.backgroundColor = VVUtility.splashBackGroundColor()
self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white, NSAttributedStringKey.font : VVUtility.normalFontWithPlusSize(increaseSize: 0.0)]
} else {
// Fallback on earlier versions
}
}
Run Code Online (Sandbox Code Playgroud)
我回忆起largeNavigationTitle()在这两个viewWillAppear和viewDidLoad
UPDATE
这里是两种状态的屏幕截图:在滑动之前:imgur.com/a/ZcSOrov 在滑动时:imgur.com/a/DYeeot8