我的工具栏按钮没有显示图像

时间:2011-02-18 06:24:18

标签: iphone image uinavigationcontroller uitoolbar

以下是我用来显示工具栏及其上的图像的代码。

   - (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"Nice Quote";
    app=(nicequote123AppDelegate *)[[UIApplication sharedApplication]delegate];
    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bac1.jpg"]];
    self.navigationController.navigationBar.barStyle=UIBarStyleBlackOpaque;


    toolbar=[UIToolbar new];
    toolbar.barStyle=UIBarStyleBlackOpaque;

    [toolbar sizeToFit];
    toolbar.frame = CGRectMake(0, 435, 320, 50);
    UIBarButtonItem *che=[[UIBarButtonItem alloc]initWithCustomView:];

    UIBarButtonItem *wifi=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"email.png"] style:UIBarButtonItemStylePlain
                                                         target:self action:@selector(send_clicked:)];
    UIBarButtonItem *wifi1=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"mobile2.png"] style:UIBarButtonItemStylePlain 
                                                          target:self action:@selector(mess_clicked:)];
    UIBarButtonItem *flexi=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 

    UIImage *img=[UIImage imageNamed:@"configuration.png"];
    UIBarButtonItem *settings1=[[UIBarButtonItem alloc] initWithImage:img style:UIBarButtonItemStylePlain 
                                                              target:self action:@selector(add:)];
    NSArray *arr=[NSArray arrayWithObjects:settings1,flexi,flexi,wifi1,wifi,nil];

    [settings1 release];
    [flexi release];
    [wifi release];
    [wifi1 release];
    [toolbar setItems:arr animated:YES];
    [self.navigationController.view addSubview:toolbar];    
    UIBarButtonItem *wifi3=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(log_clicked:)];
    self.navigationItem.rightBarButtonItem=wifi3;
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

0 个答案:

没有答案