-1
UIImage *rightIcon = [UIImage imageNamed:@"fb.jpg"];
UIBarButtonItem *btnFB = [[UIBarButtonItem alloc] initWithImage:rightIcon 
                                                          style:UIBarButtonItemStylePlain 
                                                         target:self 
                                                         action:@selector(FBConnect)];
[_barItems insertObject:btnFB atIndex:0];

このコードを書きましたが、画像をTabBar.

4

1 に答える 1

0
self.navigationItem.rightBarButtonItem = [self getfbBtn];

- (UIBarButtonItem *) getfbBtn
{
    UIButton * backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setFrame:CGRectMake(0.0f,0.0f,22.0f,22.0f)];
    [backBtn setImage:[UIImage imageNamed:@"fb.jpg"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(FBConnect) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    return backBarButton;    
}

//Action For RightBarButton - FBBtn
- (void)FBConnect
{
    NSLog(@"fb connect btn press");
}
于 2012-09-01T11:12:25.203 に答える