众所周知UINavigationController从左到右推送ViewController,有没有办法将视图从右推到左?喜欢后退按钮的动画.
现在我有这个:
[self.navigationController pushViewController:viewController animated:YES];
Run Code Online (Sandbox Code Playgroud) 如何使用setTitleTextAttributes:forState:在UIBarItem中iOS?
你怎么设置的NSDictionary?不能使它工作,文档不是很清楚.
从文档:
setTitleTextAttributes:forState:
Run Code Online (Sandbox Code Playgroud)
设置给定控件状态的标题文本属性:
- (void)setTitleTextAttributes:(NSDictionary *)attributes
forState:(UIControlState)state
Run Code Online (Sandbox Code Playgroud)
参数:
attributes:包含文本属性的键值对的字典.您可以使用NSString UIKit Additions Reference中列出的键指定字体,文本颜色,文本阴影颜色和文本阴影偏移.
state:要为其设置标题文本属性的控件状态.
如何更改导航栏的后退按钮的字体.
后退按钮是"后退"或前一个视图控制器的标题.
我认为这viewDidLoad会奏效:
navigationController?.navigationItem.leftBarButtonItem?.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "FONTNAME", size: 20)!], forState: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)
但是leftBarButton?可选的退货nil.
cocoa-touch uinavigationbar uinavigationcontroller ios swift
我的应用程序的主页有UIButtons,btnIncome和btnExpense.光标移动到该按钮按下IncomeVC和ExpenseVCrespectevely,这是两个UIViewControllers与UITabBar经由XIB加入.tabBar有4个项目.选择在每个标签项目添加相同的四个视图控制器(包含UITableViews)作为的子视图IncomeVC和ExpenseVC,像例如,DailyVC,WeeklyVC,MonthlyVC,YearlyVC.(即,对于收入,有每天,每周等和相同的用于费用)(我已经这样做了,因为IncomeVC并且ExpenseVCa UIButton和a UIView对于所有选项卡都是通用的).
所以问题是,如果点击btnIncome我必须使用与收入相关的数组填充这些表视图,反之亦然.如何从哪个viewController中找到我选择的不同选项卡(我需要从我添加的4个视图中获取它作为IncomeVC和ExpenseVC的子视图).我是否必须为收入和费用制作8个不同的视图4?感谢名单.
iphone uitabbarcontroller uiviewcontroller uinavigationcontroller
所以我有一个登录视图,成功登录后,它会进入导航控制器的第一个视图,然后用户可以更深入地进入设置视图,然后进入注销视图.此注销应该将用户带回登录视图(不是导航控制器的一部分).它适用于以下代码:
let loginViewController = self.storyboard!.instantiateViewControllerWithIdentifier("Login") as? LoginViewController
self.navigationController!.pushViewController(loginViewController!, animated: true)
Run Code Online (Sandbox Code Playgroud)
但登录视图显示顶部的导航栏,它不应该这样做,可能还有self.navigationController!.pushViewController我应该使用的东西吗?
我多次偶然发现,从未找到解决方案.UINavigationController的navigationBar可以设置为黑色半透明,如:
self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;
Run Code Online (Sandbox Code Playgroud)
另外,在UINavigationBar中有一个半透明的属性,文档说:
如果是,则无论条形样式如何,导航栏都会以部分不透明度绘制.不透明度是固定的,不能更改.当导航栏由导航控制器对象管理时,允许设置此属性的值.
我试过了
self.navigationcontroller.navigationBar.tintColor=[UIColor blueColor];
self.navigationcontroller.navigationBar.translucent=YES;
Run Code Online (Sandbox Code Playgroud)
和千种变化:首先设置半透明属性,在AppDelegate和ViewController中设置它,首先设置barstyle.结果总是一样的:没有透明度.因此我的问题是:
是否真的可以将半透明UINavigationBar的颜色更改为不同于黑色的颜色(最好是在UINavigationController中)?
我希望有一个审查安全的解决方案.
谢谢,m
我试图在我的segue中设置一个属性时遇到了崩溃.这是一个UIView将属性传递给一个导航控制器,它有一个TableView作为它的根视图.它应该转到我的TableViewController,但它看起来像是被NavigationController截获并抛出一个无法识别的选择器错误.
Segue公司:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showItems"]) {
ShowItemsTableViewController *destinationViewController = [segue destinationViewController];
[destinationViewController setItems:[self itemsFromCoreData]];
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
-[UINavigationController setItems:]: unrecognized selector sent to instance 0x10920c840
这里发生了什么?NavigationController没有与之关联的类,它只是在故事板中并以模态方式出现.如果我将故事板中的segue设置为直接转到视图而不是NavigationController,它可以工作,但我真的需要导航那里.我该如何解决这个问题?
在我的应用程序中,我想使用'Back'文本作为每个viewcontroller的后退按钮标题.我已经在stackoverflow上阅读了这么多帖子但什么也没得到.
我不想设置leftbarbuttonitem.
任何人都可以帮我完成这个简单的任务.
谢谢,
我正在尝试使用iOS 8中添加的新功能 - 在用户滚动表格视图时隐藏导航栏(类似于移动Safari的功能).我设置的财产hidesBarsOnSwipe的UINavigationController,以YES在viewDidAppear的方法UITableViewController:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if([self.navigationController respondsToSelector:@selector(hidesBarsOnSwipe)]) {
self.navigationController.hidesBarsOnSwipe = YES;
}
}
Run Code Online (Sandbox Code Playgroud)
滚动视图时,导航栏会隐藏.到现在为止还挺好.但状态栏仍然可见,我的表视图内容通过它显示,看起来很丑:

我试着设置edgesForExtendedLayout于UIEdgeRectNone或调节contentInset表视图,但它并没有帮助.是否有任何其他解决方案可以隐藏状态栏和导航栏,或使其不透明?
最小的可重现示例(Xcode 11.2 beta,在Xcode 11.1中有效):
struct Parent: View {
var body: some View {
NavigationView {
Text("Hello World")
.navigationBarItems(
trailing: NavigationLink(destination: Child(), label: { Text("Next") })
)
}
}
}
struct Child: View {
@Environment(\.presentationMode) var presentation
var body: some View {
Text("Hello, World!")
.navigationBarItems(
leading: Button(
action: {
self.presentation.wrappedValue.dismiss()
},
label: { Text("Back") }
)
)
}
}
struct ContentView: View {
var body: some View {
Parent()
}
}
Run Code Online (Sandbox Code Playgroud)
问题似乎在于将我放置NavigationLink在navigationBarItems嵌套于SwiftUI视图(其根视图为)的修改器内部NavigationView。崩溃报告表明,当我向前导航Child然后返回时,我试图弹出一个不存在的视图控制器Parent …
ios ×6
objective-c ×4
swift ×4
iphone ×2
back-button ×1
cocoa-touch ×1
ios8 ×1
segue ×1
swiftui ×1
title ×1
translucency ×1
uibaritem ×1
uicolor ×1
xcode11.2 ×1