gpt4 book ai didi

ios - 在 UITableViewController IOS 中扩展 UIViewController

转载 作者:行者123 更新时间:2023-11-29 00:38:33 24 4
gpt4 key购买 nike

我正在使用一个包含通用自定义按钮的 View Controller 。我在需要这些按钮的地方使用这个类。就像在这个类名 logOutViewController 中创建一个注销按钮,并在我需要显示注销按钮的地方使用这个类。

#import "logOutViewController.h"
@interface TableViewController : logOutViewController

上面的代码显示了所需 View Controller 上的注销按钮。

这段代码在除 UITaleViewController 之外的所有 View Controller 中都能正常工作。因为在导入 logOutViewController.h 之后,如果我替换了

#import "logOutViewController.h"
@interface TableViewController : UITableViewController

UITableViewController 到 logOutViewController 然后 UITableViewController 类中的默认函数开始出错。

uiviewcontroller类uitableviewcontroller类的功能应该怎么获取呢

最佳答案

您可以使用 UIViewController,如果您说它可以正常工作,只需使用 TableView 委托(delegate)方法即可。例如

@interface TableViewController : logOutViewController <UITableViewDelegate, UITableViewDataSource>

并使用所有需要的方法。不要忘记创建您的 UITableView

@property (nonatomic, weak) IBOutlet UITableView *tableView

并与IB中手动添加的tableView连接。

希望对你有帮助

关于ios - 在 UITableViewController IOS 中扩展 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40039111/

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