我只是想设置一个简单的故事板。我在View Controller
中嵌入了Navigation Controller
,它是应用的起始视图。我在其中添加了整页Table View
和Table View Cell
。
然后我想在顶部添加两个Bar Button Items
,但是当我将它们拖入时,那就是问题所在。当我将它拖到顶部栏上时,它会在底部创建一个新栏并将其附加到那里。当我转到文档大纲并手动将其拖动到Navigation Item
中的View Controller
下时,它会起作用并转到右上角。
但是我没有办法在左上角添加第二个Bar Button Item
- 当我拖入一个时,它会移到底部,如果我尝试将其放在Navigation Item
下文档大纲和第一个文档大纲一样,它就不再存在,好像只允许一个Bar Button Item
一样。
我做错了什么?这在过去一直很好。
答案 0 :(得分:1)
有时故事板有糟糕的日子,xCode有bug。然后代码来救援:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
showCalendar.frame = CGRectMake( 0, 0, 40, 30 );
[showCalendar setImage:[UIImage imageNamed:@"calendar"] forState:UIControlStateNormal];
[showCalendar addTarget:self action:@selector(METHOD CALL) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
您可以在左侧重复添加其他按钮的过程。