UISplitViewController仅详细信息inputAccessoryView [英] UISplitViewController detail-only inputAccessoryView
问题描述
我正在尝试根据消息输入工具栏模仿Apple的iMessage应用程序。 Apple有一个 UIToolbar
这是它包含的 UITextView
的输入附件视图,还有 inputAccessoryView
实际视图。这样,工具栏总是存在,当键盘出现时,它会随键盘滑动。
I am trying to imitate Apple's iMessage application in terms of the message input toolbar. Apple has a UIToolbar
which is the input accessory view of a UITextView
it contains, and also the inputAccessoryView
of the actual view. That way, the toolbar is always present, and when the keyboard appears, it slides with the keyboard.
在iPad上,它们似乎有一个 UISplitViewController
,工具栏是详细视图控制器的一部分。现在,当我进行相同的设置时,我的详细视图的输入附件工具栏会拉伸到整个宽度,因此就像键盘一样,它也会与主视图控制器重叠。另一方面,Apple以某种方式设法将输入附件限制为详细视图的约束。
On the iPad, they seem to have a UISplitViewController
, and the toolbar is part of the detail view controller. Now, when I have the same set up, my detail view's input accessory toolbar stretches to the whole width, so just like the keyboard, it also overlaps the master view controller. Apple, on the other hand, somehow managed to restrict the input accessory to the constraints of the detail view.
我该怎么做?
推荐答案
只有 UISplitViewController中的一个viewController inputAccessoryView
是不可能的/ code>。
我的方法是将 inputAccessoryView
作为容器,并在其中包含 320px
偏移量的子视图。
That's not possible to have inputAccessoryView
only for one viewController in UISplitViewController
.
My way to do it is to have inputAccessoryView
as container and have subview in it with 320px
offset.
- (void)setFrame:(CGRect)frame
{
if (RUNNING_ON_IPAD)
{
CGFloat superviewWidth = self.superview.bounds.size.width;
CGFloat offset = 321.f;
frame.origin.x = offset;
frame.size.width = superviewWidth - offset;
}
[super setFrame:frame];
}
这篇关于UISplitViewController仅详细信息inputAccessoryView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!