gpt4 book ai didi

ios - 在选项卡栏中的 View Controller 中重用栏按钮项的功能

转载 作者:行者123 更新时间:2023-11-29 01:51:50 26 4
gpt4 key购买 nike

如何在选项卡栏的 View Controller 中重用栏按钮项的功能(以编程方式添加)?

enter image description here

此外,我想在导航栏中的其他 View Controller 中显示栏按钮项目(以编程方式添加)。我想在其他四个 View Controller 中重用第一个 View Controller 中编写的代码。

最佳答案

因此您希望每个屏幕都显示顶部。最好的方法是:

1) 创建一个 uiviewcontroller- TOPBARVIEWCONTROLLER :UIViewController 并在顶部栏中添加按钮和你想要的东西。

例如,

@property (nonatomic, strong) UILabel *headerLBL;
-(void)setHeaderTitle:(NSString *)strHeading;

2) 现在在您想要顶部栏的另一个 viewController 类中,

#import "TOPBARVIEWCONTROLLER.h"

而不是使用:picgramViewcotroller: UIViewController使用:picgramView Controller :TOPBARVIEWCONTROLLER 在.h文件中

在 .m 文件中,在 viewdidload 中,调用:

[self setHeaderTitle:@"New header title"];

关于ios - 在选项卡栏中的 View Controller 中重用栏按钮项的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31309207/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com