我有一个 UITableViewController。我想在底部有一个“工具栏式”组件。
我从使用背景图像和按钮开始。在界面生成器中,我将它们添加到 iPhone 屏幕的底部。我遇到的问题是背景图像和按钮随表格滚动。我显然需要把它固定在底部。
在网上找不到太多方向,我决定自定义一个 UIToolbar 来看看我想要的样子,因为默认情况下位置是固定的。在我的 UITableViewController 的 initWithNibName 中,我有:
UIImage *shuffleButtonImage = [UIImage imageNamed:@"shuffle_button.png"];
NSArray* toolbarItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithImage:shuffleButtonImage
style:UIBarButtonItemStylePlain
target:self
action:@selector(push:)],
nil];
[toolbarItems makeObjectsPerformSelector:@selector(release)];
self.toolbarItems = toolbarItems;
我现在遇到的问题是“shuffleButtonImage”没有正确显示。按钮的形状显示得很好,但它是白色的,因此看起来不像图像。
有谁知道为什么会显示“白色图像”而不是实际图像?
自定义 UIToolbar 听起来是个好主意,还是有一种简单的方法来确保固定位置的“工具栏式”组件。
重申一下——我的“工具栏式”组件只需要在我的 UITableView 的按钮上是一个按钮。单个按钮具有我用图像创建的渐变色背景。