我正在尝试添加UIBarButtonItem,其样式为UIBarButtonSystemItemCompose。根据苹果文档,它应该显示一个由方形轮廓组成的组合图标。当我使用以下代码时,它只显示一个红色按钮。如果uibarbuttonitem放置在UIToolBar而不是导航栏内,该图标是否仅起作用。
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle:nil
style:UIBarButtonSystemItemCompose
target:self
action:@selector(tweetPressed:)] autorelease];
答案 0 :(得分:3)
您正在错误地创建按钮。您需要使用正确的init...
方法。
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(tweetPressed:)];
self.navigationItem.rightBarButtonItem = btn;
[btn release];
查看您使用的init...
方法的文档。查看应为style
参数传递的类型,并查看有效值。