我想在我的导航控制器的标题中添加一个字符符号(例如空白字符后跟子弹符号"•")UINavigationBar.根据我的应用程序的状态,我想改变子弹的前景色.
我想过使用属性字符串可以改变颜色.但是,我没有找到直接访问标题并为其分配属性字符串的方法.
您建议在一个解决方案中添加字符符号UINavigationBar以及能够更改其颜色的解决方案是什么?
谢谢!
我以模态方式呈现UINavigationController.
_navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
Run Code Online (Sandbox Code Playgroud)
我想展示带圆角的模态控制器.我试过这个:删除uiviewcontroller的视图ipad的圆角
它与UIViewControllers一起工作正常.对于UINavigationController,我尝试将导航控制器视图的圆角半径设置为0.还设置UINavigationController内所有UIViewControllers的UIViews的圆角半径.但没有任何工作.
任何人都知道怎么做?
好吧,在深入深渊(即iOS私人课程)和最终可重复使用代码的讨伐之间存在着一条很好的界限.
我想在UINavigationBar下面有一个任意UIView,大约40像素高.现在,通常这可以在封闭的视图中抛出,但我希望这个UIView 留在UINavigationBar中.因此,当用户向下钻取到不同视图时,导航栏下方的UIView将保持存在.
我已经尝试构建一个容器UIViewController,它将被放置为UINavigationController中的RootViewController,但是这没有用,因为当用户推送新视图时,我的容器视图被滑出,而我的持久性栏顺其自然.
如果我在UIViewController中放置一个UINavigationController,我可以覆盖我想要的UIView条,但内部视图似乎仍然没有正确地改变它们的框架,以及当从导航堆栈推出或弹出视图时,由于UINavigationController不知道屏幕下方的新Y位置,因此视图动画效果不佳(更改其Y位置以及移出屏幕.)
所以,我研究了UINavigationController的子类化.我知道,它说" 这个类不是用于子类化的. ",但总有例外.这个子类可以简单地在导航栏下面添加持久性UIView,调整内容部分的大小(普通视图将出现的位置),一切都会正常工作.
但是在使用ObjC运行时类之后,我找不到调整的魔术变量来使其工作(UINavigationController的_containerView就是这样一个变量).
最好的方法是什么?有没有比复制和粘贴代码更好的方法,使这个Bar成为将显示它的所有ViewControllers?
我需要使用子类UIToolbar中的子类UINavigationController.我知道这可以通过Interface Builder但我需要以编程方式完成.
文档声明UINavigationController工具栏属性是只读的,所以我对如何继续有点不知所措.
有关:
我目前有一个UINavigationController的子类,它具有以下viewDidLoad函数.
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"HI"
style:UIBarButtonItemStylePlain
target:self
action:@selector(manage)];
[self.navigationItem setLeftBarButtonItem:leftButton];
[self.navigationBar setBackgroundImage:[[UIImage imageNamed:@"top_nav_bg.png"] stretchableImageWithLeftCapWidth:3.0 topCapHeight:0.0] forBarMetrics:UIBarMetricsDefault];
}
Run Code Online (Sandbox Code Playgroud)
UINavigationController子类是UITabBarBarController子类中的一个选项卡,具有以下viewDidLoad.
- (void)viewDidLoad
{
[super viewDidLoad];
// Change some of the look of the main tab bar
[self.tabBar setBackgroundImage:[[UIImage imageNamed:@"tab_nav_bg.png"] stretchableImageWithLeftCapWidth:2.0 topCapHeight:0.0]];
[self.tabBar setSelectionIndicatorImage:[[UIImage imageNamed:@"tab_nav_bg_active.png"] stretchableImageWithLeftCapWidth:2.0 topCapHeight:0.0]];
// Load the various view controllers for this view
SBHomeViewController *homeViewController = [[SBHomeViewController alloc] init];
[homeViewController.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tab_home_active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_home.png"]];
[homeViewController.tabBarItem setImageInsets:UIEdgeInsetsMake(5.0, 0.0, -5.0, 0.0)];
// The navigation controller …Run Code Online (Sandbox Code Playgroud) iphone uitabbarcontroller uinavigationcontroller uinavigationitem
我在导航控制器中有两个视图控制器.第一个视图控制器有一个带按钮的菜单.按此按钮移动到第二个视图控制器并将html字符串加载到UIWebView中.没有其他任何东西被加载到webview,只是一个带有html代码的简单NSString.基本上我正在使用webview作为其中一个uiviews的子视图制作翻转卡片(两个视图).
这是代码:
containerView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 280)];
[self.view addSubview:containerView];
frontView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 280)];
frontView.layer.cornerRadius = 10;
frontView.layer.masksToBounds = YES;
[frontView setBackgroundColor:[UIColor whiteColor]];
backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 280)];
backView.layer.cornerRadius = 10;
backView.layer.masksToBounds = YES;
[backView setBackgroundColor:[UIColor yellowColor]];
[containerView addSubview:frontView];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 280, 280)];
webView.scalesPageToFit = YES;
webView.userInteractionEnabled = NO;
NSString *htmlString = @"<head><meta name='viewport' content='width=device-width;'><style type='text/css'>html,body {margin: 0;padding: 0;width: 100%;height: 100%;}html {display: table;}body {display: table-cell;vertical-align: middle;padding: 20px;text-align: …Run Code Online (Sandbox Code Playgroud) performance objective-c uiwebview uinavigationcontroller ios
我已经使用下面的代码创建了一个自定义后退按钮,但可点击区域非常大,远远超出了图标本身.有谁知道如何设置可点击区域,或使其与图像大小相同?
谢谢
UIImage *buttonImage = [UIImage imageNamed:@"prefs"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action: @selector(handleBackButton)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
Run Code Online (Sandbox Code Playgroud)
可点击区域显示为红色.

谢谢!
iphone uinavigationbar uinavigationcontroller uinavigationitem ios
所以我的导航控制器中有一个设置栏按钮项,当从家庭视图控制器按下时,会在家庭视图上打开设置vc透明视图,因此家庭vc仍然可以在设置vc后面看到.我希望导航栏仍然显示,所以在"HomeViewController.h"中我有以下代码:
-(IBAction)settingsButtonPressed:(id)sender{
SettingsViewController *settings = [[SettingsViewController alloc]init];
[self.navigationController.view addSubview:settings.view];
}
Run Code Online (Sandbox Code Playgroud)
当我想删除设置视图时,在"SettingsViewController"中我尝试了:
-(IBAction)exitSettings:(id)sender{
[self.navigationController.view removeFromSuperview];
}
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做并尝试运行程序时,程序停止,而在调试区域,它只是说
Thread 1: EXC_BAD_ACCESS (code = 2, address=0xb0000008)
(lldb)
Run Code Online (Sandbox Code Playgroud)
我做错了什么,如何解决这个问题?
我正在使用自定义导航栏.在我,AppDelegate我做到了这一点.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes: @{
UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeTextShadowColor: [UIColor whiteColor],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],
UITextAttributeFont: [UIFont fontWithName:@"Carrois Gothic" size:18.0f]
}];
Run Code Online (Sandbox Code Playgroud)
在viewController级别我把按钮放在里面navigationController.总而言之,viewControllers我只有一个按钮navigationbar.
但在一个VC我需要设置2个按钮,我也改变backgroundImage了navigationbar.所以我复制了与上面相同的代码ViewDidLoad但现在使用其他图像.这很有效.
但现在我想要所有其他VC的第一个navigationbar.所以在我viewDidDisappear再次复制代码与另一个图像.
以下是错误的:
任何人都可以帮我吗?
PS:我正在和一个人合作tabbarcontroller.因此,如果我说切换VC,我的意思是转到tabbarcontroller中的另一个选项卡
objective-c uinavigationbar uitabbarcontroller uinavigationcontroller ios
我已经实现了一个搜索表单的自定义版本,其行为很像带有范围栏的UISearchBar(但实际上由于UI原因而以编程方式拼凑在一起).屏幕加载TextField,您点击TextField,导航栏在屏幕上显示动画,文本字段向上移动,并显示分段控件以过滤结果.
无论如何,这一切都有效,但当我点击其中一个搜索结果时,我的代码推送了一个新的ViewController.问题是新控制器在没有导航栏的情况下被推送(因为我[[self navigationController] setNavigationBarHidden:YES animated:YES]在切换到搜索状态时使用).
我可以显示导航栏,因为新的ViewController被推送,甚至在转换到新的ViewController时显示动画 - 但所有这些解决方案看起来都很笨拙.我希望它像使用UISearchBar(实际上更像是电子邮件应用程序)一样工作,因为恢复的导航栏似乎只是从右侧滑入,就像它是子视图控制器的一部分一样.
我希望有一个简单的解决方案......谢谢