【发布时间】:2024-10-07 12:50:02
【问题描述】:
我在 UINavigationController 中有一个 UITableView。为了在屏幕底部制作一个不随表格单元格移动的工具栏,我添加了一个 UIView 作为导航栏的子视图。
然后我以编程方式创建一个 UIButton 来添加这个 UIView。我添加了一个选择器,但它没有注册并调用了我将它设置为的函数(sendMessage)。
self.sendBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-100, self.view.frame.size.width,100 )];
self.sendBar.backgroundColor = cloudBlue;
UIButton *sendButton = [[UIButton alloc] initWithFrame:CGRectMake(0,0,50,50)];
sendButton.backgroundColor = [UIColor blackColor];
[sendButton addTarget:self action:@selector(sendMessage) forControlEvents:UIControlEventTouchUpInside];
[self.navigationController.navigationBar addSubview:self.sendBar];
[self.sendBar addSubview:sendButton];
【问题讨论】:
标签: ios objective-c xcode uibutton