【发布时间】:2013-02-05 10:00:28
【问题描述】:
我创建了一个UIToolBar 并想在其中添加三个项目,例如联系人、日期和消息。我试过了,但我做不到。请帮助,因为我是 Objective C 的新手。这是我的"ViewController.m"
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0, 414, self.view.frame.size.width, 44);
UIBarButtonItem *contact = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:nil];
UIBarButtonItem *message = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
NSMutableArray *items = [[NSMutableArray alloc] initWithObjects:contact,message, nil];
[toolbar setItems:items animated:NO];
[items release];
[self.view addSubview:toolbar];
[toolbar release];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
【问题讨论】:
-
评论[项目发布];和[工具栏发布];并尝试一次。让我知道它是否有效..
-
评论这些行没有任何区别..
标签: iphone ios objective-c ios6