моя кнопка на панели инструментов не показывает изображение - PullRequest
0 голосов
/ 18 февраля 2011

Вот код, который я использовал для отображения панели инструментов и изображения на ней.

   - (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;
}
...