在本文中,我们将为您详细介绍iphone–在UINavigationController上创建后箭头形状leftBarButtonItem的相关知识,并且为您解答关于ios15箭头的疑问,此外,我们还
在本文中,我们将为您详细介绍iphone – 在UINavigationController上创建后箭头形状leftBarButtonItem的相关知识,并且为您解答关于ios15箭头的疑问,此外,我们还会提供一些关于ios – navigationItem setRightBarButtonItems间距太宽、ios – UINavigationBar -pushNavigationItem在将新控制器推送到UINavigationController堆栈时从不调用、ios – UINavigationBar没有UINavigationController、iOS – UINavigationController,隐藏navigationBar的有用信息。
本文目录一览:- iphone – 在UINavigationController上创建后箭头形状leftBarButtonItem(ios15箭头)
- ios – navigationItem setRightBarButtonItems间距太宽
- ios – UINavigationBar -pushNavigationItem在将新控制器推送到UINavigationController堆栈时从不调用
- ios – UINavigationBar没有UINavigationController
- iOS – UINavigationController,隐藏navigationBar
iphone – 在UINavigationController上创建后箭头形状leftBarButtonItem(ios15箭头)
我可以创建一个基本按钮,但我真的想要左箭头形状 – 这就是我现在拥有的:
/* set title and nav bar items */ self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back To Thumbnails" style:UIBarButtonItemStylePlain target:self action:@selector(backToThumbnails:)] autorelease];
我在这里只看到了三种风格选择?任何建议都非常感谢!
解决方法
ios – navigationItem setRightBarButtonItems间距太宽
我正在使用
navigationItem setRightBarButtonItems
设置两个按钮项目,但它们相距太远.
我试过添加负空间,我试过在它之后添加一个垫片,固定空间,灵活的空间.在文档中没有看到任何说你无法改变间距但我找不到的方法.
我在这里先向您的帮助表示感谢.
编辑后编辑:
Siu Chung Chan的回答是完全正确的,但由于我一开始并没有得到它,我想我会分享让我意识到他完全正确的代码.
如果你把它全部放在一个区块中,这就是他(非常正确)的答案:
UIView *filterBtnView = [[UIView alloc] initWithFrame:CGRectMake(0,35,35)]; UIButton *filterBtn = [[UIButton alloc] initWithFrame:CGRectMake(0,35)]; [filterBtn addTarget:self action:@selector(someMethod) forControlEvents:UIControlEventTouchUpInside]; [filterBtn setBackgroundImage:[UIImage imageNamed:@“someicon”] forState:UIControlStatenormal]; [filterBtnView addSubview:filterBtn]; UIBarButtonItem *btnFilter = [[UIBarButtonItem alloc] initWithCustomView:filterBtnView]; UIView *selectBtnView = [[UIView alloc] initWithFrame:CGRectMake(0,35)]; UIButton *selectBtn = [[UIButton alloc] initWithFrame:CGRectMake(0,35)]; [selectBtn setBackgroundImage:[UIImage imageNamed:@“someothericon”] forState:UIControlStatenormal]; [selectBtn addTarget:self action:@selector(someOtherMethod:) forControlEvents:UIControlEventTouchUpInside]; [selectBtnView addSubview:selectBtn]; UIBarButtonItem *btnSelect = [[UIBarButtonItem alloc] initWithCustomView:selectBtnView]; [self.navigationItem setRightBarButtonItems:@[btnFilter,btnSelect] animated:YES];
对我来说,这样做的好处在于它可以让人看到苹果实际设置的一些观点是如何偏向他们只想使用它们的.因此,如果您想要进行高度自定义的UI,您必须进行大量的UIView操作以绕过它们(可能)的意外障碍.
故事的道德:如果视图没有正确排列,请尝试从UIView级别重新创建视图,然后将其添加到要显示它的视图中.
再次感谢Siu Chung Chan!
解决方法
您必须为按钮创建自己的UIView.
导致默认的uibarbuttonitem左侧和右侧有一些填充.
ViewIconBtn* searchViewIconBtn = [[ViewIconBtn alloc] initWithImage:[UIImage imageNamed:@"searchIcon.png"]]; [searchViewIconBtn.btn addTarget:self action:@selector(toSearch) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem* btnSearch = [[UIBarButtonItem alloc] initWithCustomView:searchViewIconBtn]; UIBarButtonItem *space15 = [NegativeSpacer negativeSpacerWithWidth:15]; [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:space15,btnWishList,btnPost,btnSearch,nil]];
btnWishList,btnSearch都是ViewIconBtn类.
在我的项目中,我在右侧创建了3个导航按钮.
UIBarButtonItem space15用于调整边界和最右边的按钮之间的填充.
ios – UINavigationBar -pushNavigationItem在将新控制器推送到UINavigationController堆栈时从不调用
- (void)pushController { PHViewController *ctrl2 = [[[PHViewController alloc] initWithNibName:@"PHViewController" bundle:nil] autorelease]; ctrl2.shouldShowPrompt = YES; [self.viewController pushViewController:ctrl2 animated:YES]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. PHViewController *ctrl = [[[PHViewController alloc] initWithNibName:@"PHViewController" bundle:nil] autorelease]; ctrl.shouldShowPrompt = YES; ctrl.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Push" style:UIBarButtonItemStyleDone target:self action:@selector(pushController)] autorelease]; self.viewController = [[[PHNavigationController alloc] initWithRootViewController:ctrl] autorelease]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; }
现在我已经将UINavigationController的UINavigationBar子类化了(我知道这是非法的,这是一个教育问题)我已经覆盖了以下方法:
- (void)setItems:(NSArray *)items animated:(BOOL)animated { NSLog(@"Setting Navigation Item"); [super setItems:items animated:animated]; } - (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated { NSLog(@"Pushing Navigation Item"); [super pushNavigationItem:item animated:animated]; } - (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated { NSLog(@"Poping Navigation Item"); return [super popNavigationItemAnimated:animated]; } - (void)setValue:(id)value forKeyPath:(Nsstring *)keyPath { NSLog(@"Setting Value: %@ for keyPath:%@",value,keyPath); [super setValue:value forKeyPath:keyPath]; }
这是我的问题:为什么控制台中存在“弹出导航项”(因此被调用的方法)和“推送导航项”不是?
解决方法
还是非常感谢!
ios – UINavigationBar没有UINavigationController
具有UINavigationBar的视图控制器具有.xib文件中的视图.我试图从对象库拖动一个UINavigationBar的实例,它的工作正常,但是应用程序的状态栏仍然是白色的,而UINavigationBar是灰色的.我想要状态栏具有相同的灰色调,但不是其余的视图.
告诉你我的意思,我有两张照片.第一个是手机应用程序.请注意,状态栏和导航栏为灰色,但背景为白色.
以下图片来自我的应用程序,因为您可以看到状态栏是白色的(我也希望它是灰色的).
我也试图在视图控制器中使用以下代码.
- (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"Köp ProViva"; }
我尝试过它有无UINavigationBar,但是没有导航栏显示,或者看起来和以前一样.
如何添加一个UINavigationBar并且状态栏具有相同的颜色?
解决方法
例:
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { return UIBarPositionTopAttached; }
//if you're not using a `UINavigationController` and instead //simply want a `UINavigationBar` then use the following method as well -(void)testMethod { UINavigationBar *navBar = [[UINavigationBar alloc] init]; [navBar setFrame:CGRectMake(0,20,self.view.frame.size.width,44)]; [navBar setBarTintColor:[UIColor lightGrayColor]]; [navBar setDelegate:self]; [self.view addSubview:navBar]; }
希望这可以帮助.
iOS – UINavigationController,隐藏navigationBar
我已经添加了:
self.navigation!.navigationBar.hidden = true
不幸的是,这留下了一些背景(白色)留在白色状态栏后面向内推(绿色)向下,以及一个不需要的滚动行为,我可以上下拖动内容来显示/隐藏白色背景.我需要的是状态栏不占用任何垂直空间而是放在内容之上(绿色)
我该如何实现这一目标?
快速以及obj-c的答案非常受欢迎
编辑:
我试过以下各种版本,问题依然存在 – .-
override func loadView() { self.view = UIView(frame:UIScreen.mainScreen().bounds) self.view.backgroundColor = UIColor.whiteColor() self.navigation = UINavigationController(rootViewController: self.guideViewController!) self.navigation!.navigationBarHidden = true self.navigation!.setNavigationBarHidden(true,animated: true) self.view.addSubview(self.navigation!.view) } override func viewDidLoad() { self.automaticallyAdjustsScrollViewInsets = false self.navigation!.automaticallyAdjustsScrollViewInsets = false }
编辑2:
打印:
UIApplication.sharedApplication().statusBarFrame.size.height
在viewDidLoad返回20之后
解决方法
只需在ViewDidLoad方法中添加它即可
self.automaticallyAdjustsScrollViewInsets = NO;
今天关于iphone – 在UINavigationController上创建后箭头形状leftBarButtonItem和ios15箭头的分享就到这里,希望大家有所收获,若想了解更多关于ios – navigationItem setRightBarButtonItems间距太宽、ios – UINavigationBar -pushNavigationItem在将新控制器推送到UINavigationController堆栈时从不调用、ios – UINavigationBar没有UINavigationController、iOS – UINavigationController,隐藏navigationBar等相关知识,可以在本站进行查询。
本文标签: