- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在关注来自 here 的第二条提示.在本技巧中,两个 UIBarButtonItem 被放在一个 UIToolbar 中。最后,将 UIToolbar 添加到 UINavigationBar。现在解决我的问题:
1) UIToolbar 顶部有一条白线。如果我增加 UIToolbar 的大小,渐变是错误的。我为 UIToolbar 使用以下尺寸:
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 90, 44.01)];
如何去除白线?看这里:
问题是有一条白色线而不是灰色线。如果它是灰色的,一切都会很完美。
2) iPhone 3 和 iPhone 4 的显示尺寸有何不同?我是否必须检查使用的是哪部 iPhone,然后将尺寸加倍?
编辑:
按钮的创建方式与我从上述网站获取的以下示例类似:
// create a toolbar to have two buttons in the right
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
// create a standard "add" button
UIBarButtonItem* bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:NULL];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
// create a spacer
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[buttons addObject:bi];
[bi release];
// create a standard "refresh" button
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
// stick the buttons in the toolbar
[tools setItems:buttons animated:NO];
[buttons release];
// and put the toolbar in the nav bar
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
@tc.:
我试图子类化 UIToolbar
。
// MyToolbar.h
#import <Foundation/Foundation.h>
@interface MyToolbar : UIToolbar {
}
@end
// MyToolbar.m
#import "MyToolbar.h"
@implementation MyToolbar
- (void)drawRect:(CGRect)rect {
// do nothing
}
- (id)initWithFrame:(CGRect)aRect {
if ((self = [super initWithFrame:aRect])) {
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
self.clearsContextBeforeDrawing = YES;
}
return self;
}
@end
最佳答案
无法保证 UIToolbar 在 UINavigationBar 内无缝绘制;这可能是您看到的白线的原因。
您可以继承 UIToolbar 使其不绘制(即重写 -drawRect: 不做任何事情)。
关于iphone - 将带有两个 UIBarButtonItem 的 UIToolbar 添加到 UINavigationBar : poor UIToolbar and what about iPhone 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3789283/
我有一个简单的 UITableViewController 和一个 NavigationController 作为 Root View Controller 。我在导航栏中添加了“选项”UIBarBu
我正在尝试 this Apple tutorial但我发现了一个错误。有人可以帮助我吗? Disable Saving When the User Doesn't Enter an Item Name
我有一个 UIBarButtonItem 和 UIButton 作为自定义 View 。 UIButton 上有一个 addTarget:action:。在 Action 中,我展示了一个弹出窗口。我
我正在学习 iOS 开发,有两个简单且相关的问题: 1. 如何将多行项目添加到一个 UIToolBar 中,这可能吗?我想要一个 UISearchBar 和一个 UIToolbar 上的两行 UIBa
这就是我自定义 UIBarButtonItem 的方式: if DBAppSettings.imageViewForCartBarButtonItem == nil { DBAppSettin
有没有办法让UIBarButtonItem独家触摸?目前,您可以同时选择多个,但它不断使我的应用程序崩溃。 最佳答案 比继承导航栏更简单的方法,但思路相同; for(UIView *temp in s
如何在 uitoolbar 内旋转 uibarbuttonitem?因为我旋转了 uitoolbar(现在是垂直的)并且我的栏按钮项目也旋转了,但我不希望这样。 谢谢 最佳答案 UIBarButton
我创建了一个具有半透明黑色样式的工具栏,如下所示: UIToolbar *toolbar = [UIToolbar new]; toolbar.barStyle = UIBarStyleBlack;
有没有办法以动画方式启用或禁用按钮?我尝试了以下方法但没有成功。我猜测此时启用的属性无法像不透明度一样进行动画 - 但我希望我是错的。 [UIView beginAnimations:nil
在 IB 中,我可以选择一个 UIBarButtonItem,将其设置为“普通”、“自定义”并应用图像,它在 UIToolbar 或 UINavigationBar 中看起来不错。 当我尝试在代码中执
我需要更改 UIBarButtonItem 标题的字体。目前是 barbuttonItem.customView = customLabel。现在我希望添加一个选择器和目标,以便我可以获得 touch
我正在尝试偏移应用程序中的 UIBarButtonItems,由于我用于导航栏的图像,我需要它们稍微偏移,以便它们全部正确排列。我已经成功地做到了这一点: [[UINavigationBar appe
我希望使用标签访问 UIToolbar 上的 UIBarButtonItem。代码如下所示 UIBarButtonItem *myBarButtonItem=(UIBarButtonItem*)myU
我有一个自定义按钮,我想添加到导航栏上。到目前为止,这就是我的 RootViewController 中的内容(它继承了 UIViewController,UINavigationController
每当“userInput”UITextField 中没有输入时,我尝试禁用我的发送按钮(工具栏中的 UIBarButtonItem),并在有输入时启用它。这是我写的代码 - 我不太明白为什么它不起作用
我添加了一个 UIToolbar 实例和其顶部的按钮。每个按钮都属于 UIBarButtonItem 类。 我的要求是每个按钮都有一个自定义布局,我不想使用Apple提供的原生按钮样式。所以我在 In
你能看到按钮左边的距离吗?如何消除这个距离? 最佳答案 在按钮左侧添加一个间隔符,例如: UIBarButtonItem *backButtonItem = ....; UIBarButtonItem
我知道有些人已经问过这个问题,但到目前为止,答案还不是很具体。 显然苹果已经使导航栏的点击区域比实际更大,但我认为它不应该那么大。 在我的应用程序中,导航栏正下方有一个 TableView,您可以一直
我已经为 UINavigationBar 设置了自定义色调颜色(在 UINavigationController 内),这又为 UIBarButtonItems 设置适当的匹配颜色。插入 UINavi
我有一个带有两个 View 的导航栏应用程序:父 View 和 subview 。在 subview 中,我在右上角添加一个按钮,如下所示: - (void)viewDidLoad { UIB
我是一名优秀的程序员,十分优秀!