相关疑难解决方法(0)

如何在UIToolBar中添加条形按钮

我创建了一个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
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios ios6

3
推荐指数
1
解决办法
6932
查看次数

标签 统计

ios ×1

ios6 ×1

iphone ×1

objective-c ×1