使用以下帖子,我能够将UILabel添加到UIToolbar,但是,它看起来很糟糕.任何人都知道如何获取文本大小/颜色/阴影以匹配UINavigationController的标题?
导航控制器
替代文本http://www.codingwithoutcomments.com/uploads/Picture1.png
UIToolbar与UILabel
替代文本http://www.codingwithoutcomments.com/uploads/Picture2.png
我需要采取哪些步骤才能使它们匹配?
我一直在努力使用UINavigationalController在视图之间切换.我已多次使用此系统而没有问题但在我的新应用程序中它无法正常工作.
这是问题:当我推动一个新的视图控制器时,我使用以下代码:
NewViewController *newVC = [[NewViewController alloc] initWithNib:@"NewView" bundle:nil];
[self.navigationController pushViewController:newVC animated:YES];
[newVC release];
Run Code Online (Sandbox Code Playgroud)
我用来返回newVC内部的前一个视图的代码是:
[self.navigationController popViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
我正在读这可能会释放self.navigationController本身,所以我实现了这段代码:
UINavigationController *nc = [self navigationController];
[nc popViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
什么结果是平滑过渡到newVC而没有白色闪光,但是当返回到原始页面时,屏幕闪烁白色,就像它在转换回原始页面之前释放newVC一样.然而!在调试时,我在原始页面的viewWillAppear和newVC的dealloc以及带有白色闪存的viewWillAppear +转换上放置了断点,在调用newVC的dealloc之前完成所有断点.
如果有人可以帮助发光,我会非常感激.
谢谢!〜阿拉什
当我以编程方式隐藏导航栏时,如何捕获动画曲线和速度?我想将其他动画同步到这个动态过渡:)
我正在为iOS 4.2开发应用程序.我将子类UINavigationController插入两个UIImageView并使导航栏看起来是自定义的.一切都很好,但我有一点问题.我创建了自定义UIBarButtonItem和我的视图控制器内部我把它们:
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];
Run Code Online (Sandbox Code Playgroud)
它也有效,但问题是,为了完成这项工作,我需要调用它:
- (void)viewDidAppear:(BOOL)animated ;
Run Code Online (Sandbox Code Playgroud)
因此它只出现在动画之后,我可以看到非自定义按钮1秒钟,然后自定义按钮替换它.
(我试过viewWillAppear但在导航栏中没有任何附加内容)
我想知道你是否有解决方案可以解决这个问题.
PS:我从不使用IB,一切都是以编程方式制作的.
谢谢法国!
编辑1:这里的代码没有显示任何内容viewWillAppear:
- (void)viewWillAppear:(BOOL)animated {
[self setTitle:@"Jeu"];
//Bouton testflight
TIFButton *testFeedbackButton = [[TIFButton alloc]init];
[testFeedbackButton setTitle: @"Envoyer un Feedback" forState:UIControlStateNormal];
[testFeedbackButton addTarget:self action:@selector(launchFeedback) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *testFeedback = [[UIBarButtonItem alloc] initWithCustomView:testFeedbackButton];
self.navigationItem.rightBarButtonItem = testFeedback;
TIFBackButton *backButton = [[TIFBackButton alloc]init];
[backButton setTitle: @"Retour" forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(popToPrecedentViewController) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];
}
Run Code Online (Sandbox Code Playgroud) uinavigationbar uinavigationcontroller uibarbuttonitem viewdidappear ios
在我的应用程序中,我有两个UIViewControler(第一个和第二个)的UINavigationController.第一个视图控制器包含UITableView.当触摸表格的单元格时,推动第二视图控制器.我想要的是在第二个视图中将自定义文本设置为后退按钮.这是第二个视图中的代码.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Go back"
style:UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease];
}
Run Code Online (Sandbox Code Playgroud)
问题是后退按钮的文本已更改,但触摸按钮时第二个视图控制器未从堆栈中删除.
我觉得这个问题到现在应该被问过一百万次,但我仍然无法找到答案.
这是我的层次结构:UINavigationController - > UIViewController 1 - >(推送) - > UIViewController 2
UINavigationController:支持所有可能的方向UIViewController 1:仅支持portrait UIViewController 2:仅支持landscape
如何仅将UIViewController 1锁定为纵向,同时仅将UIViewController 2锁定为横向?它甚至可能吗?到目前为止,我看到的是UIViewController 2总是采用UIViewController 1的方向.
请注意,这仅适用于iOS 6.
谢谢!
我有6个子类UIViewControllers连接带有标识符的push segues.
他们去A> B> C> D> E> F. 我无法找到如何在控制器A中实现按钮的方法,该按钮会自动将所有控制器堆叠到控制器F并显示F控制器.堆叠应该在UINavigationController实例中完成,而不是通过(void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated,因为如果我使用setViewControllers方法,那么我将丢失segue标识符.泰!
objective-c uiviewcontroller uinavigationcontroller ios xcode5
我认为标题是非常自我解释的.我有一个嵌入在导航控制器中的tableView,并希望在导航栏中添加一个搜索栏.我认为在iOS 9中有关于搜索栏控制器的东西发生了变化,所以请记住这必须适用于iOS 9.这就是我所拥有的.毫无疑问,这是错误的.
UISearchController *searchController = [[UISearchController alloc]init];
self.searchController.searchBar.barTintColor = [UIColor whiteColor];
[self.navigationController addChildViewController:searchController];
Run Code Online (Sandbox Code Playgroud) 我正在UISearchController为自己实现一个,UITableView但我正在为iOS 11的自定义设置而苦苦挣扎。我的导航栏使用的是渐变图像背景,我希望搜索控制器能够匹配该渐变背景,但是我还没有找到一种设置背景图像的方法为UISearchController。它可以作为TableHeaderView在UISearchController上完美运行,但是在iOS 11中几乎没有传递任何自定义设置。
当前结果:
期望的结果:
这是我正在使用的代码:( 在viewDidLoad上调用)
private func setupSearchController() {
let searchController = UISearchController(searchResultsController: nil)
// Convert CAGradientLayer to UIImage
let gradient = Color.blue.gradient
gradient.frame = searchController.searchBar.bounds
UIGraphicsBeginImageContext(gradient.bounds.size)
gradient.render(in: UIGraphicsGetCurrentContext()!)
let gradientImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// Setup the Search Controller
searchController.searchBar.backgroundImage = gradientImage
searchController.searchBar.isTranslucent = false
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search by transaction name"
searchController.searchBar.tintColor = Color.custom(hexString: "FAFAFA", alpha: 1).value
definesPresentationContext = true …Run Code Online (Sandbox Code Playgroud) 我的应用程序内部有一个导航控制器和一个集合视图。有一个问题:我在导航栏中使用大标题,因此里面的所有内容都不是静态的。当我滚动集合视图单元格时,标题(我手动创建了该标题,并使用UILabel()它在导航栏中随意移动它)和按钮向上移动,导航栏采用iOS 10导航栏的形式,即其高度。你可以在这里看到它:
我的导航栏带有“首选大标题”的正常状态开:

当我滚动“收藏夹视图”时,一切都会发生:

所以问题很简单:如何使导航条的力保持恒定的高度?我希望它即使在滚动时也能固定。有什么想法吗?可能吗?
第二个问题,如果第一个是不可能的:我的问题的另一种解决方案是使“优先选择大标题”的导航栏更大。我尝试了这段代码:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let height: CGFloat = 50 //whatever height you want to add to the existing height
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
Run Code Online (Sandbox Code Playgroud)
但它仅适用于大标题。那么如何使导航栏更大?
ios ×7
objective-c ×3
iphone ×2
swift ×2
ios6 ×1
orientation ×1
transition ×1
uilabel ×1
uisearchbar ×1
uitoolbar ×1
xcode ×1
xcode5 ×1