解决 黑色背景问题

#import <Foundation/Foundation.h>


@interface CustomerViewController : UIImagePickerController<UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
    UIToolbar *hortoolBar;
    UIToolbar *vertoolBar;
    UIImageView *vBackView;    //垂直方向银色背景
    UIImageView *hBackView;    //水平方向银色背景
}
@property (nonatomic,retain) UIToolbar *hortoolBar;
@property (nonatomic,retain) UIToolbar *vertoolBar;
@property (nonatomic,retain) UIImageView *vBackView;
@property (nonatomic,retain) UIImageView *hBackView;

-(void)setNewController;
@end

//
//  CustomerViewController.m
//  MyUimageView
//
//  Created by wgd on 12-5-3.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "CustomerViewController.h"


@implementation CustomerViewController


@synthesize hortoolBar,vertoolBar,vBackView,hBackView;

-(CustomerViewController *)init
{
    [super init];
    [self setNewController];
    return self;
}


-(void)check:(id)sender
{
    self.showsCameraControls = NO;
    [self takePicture];   

}

-(void)cancelTakePhoto:(id)sender
{
    [self.delegate imagePickerControllerDidCancel:self];
}

-(void)setNewController
{
        
    self.vertoolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 970, 768, 54)];
    [self.view addSubview:vertoolBar];
    
    self.vBackView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 54)];
    vBackView.image = [UIImage imageNamed:@"verBackView.png"];
    [self.vertoolBar addSubview:vBackView];
    [vBackView release];
    
    UIBarButtonItem *btn1 = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonSystemItemCancel target:self action:@selector(cancelTakePhoto:)];
    btn1.width = 100;
    
    UIBarButtonItem *btn11 = [[UIBarButtonItem alloc] initWithTitle:@"" style:
                              UIBarButtonItemStylePlain target:self action:nil];
    btn11.width = 530;
    btn11.enabled = NO;
    
    UIBarButtonItem *btn2=  [[UIBarButtonItem alloc] initWithTitle:@"拍照" style: UIBarButtonSystemItemCancel target:self action:@selector(check:)];
//    UIBarButtonItem *btn2=  [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"test.png"] style:UIBarButtonSystemItemCancel target:self action:@selector(check:)];
    btn2.width = 100;
    NSMutableArray *btnArray = [[NSMutableArray alloc] initWithObjects:btn1,btn11,btn2,nil];
    vertoolBar.items = btnArray;
    [btn1 release];
    [btn11 release];
    [btn2 release];
    
    UIBarButtonItem *btn3 = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonSystemItemCancel target:self action:@selector(cancelTakePhoto:)];
    btn3.width = 100;
    UIBarButtonItem *btn31 = [[UIBarButtonItem alloc] initWithTitle:@"" style:
                              UIBarButtonItemStylePlain target:self action:nil];
    btn31.width = 790;
    btn31.enabled = NO;
    
    UIBarButtonItem *btn4=  [[UIBarButtonItem alloc] initWithTitle:@"拍照" style:UIBarButtonSystemItemCancel target:self action:@selector(check:)];
    btn4.width = 100;
    NSMutableArray *btnArray2 = [[NSMutableArray alloc] initWithObjects:btn3,btn31,btn4,nil];
    [btn3 release];
    [btn31 release];
    [btn4 release];
    
    self.hortoolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 714, 1024, 54)];
    self.hBackView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0 , 1024, 54)];
    hBackView.image = [UIImage imageNamed:@"horBackView.png"];
    [hortoolBar addSubview:hBackView];
    [hBackView release];
    hortoolBar.items = btnArray2;
    [self.view addSubview:hortoolBar];
    
    
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{    
    return  YES;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    self.showsCameraControls = NO;
   
    if(UIDeviceOrientationLandscapeRight ==toInterfaceOrientation||
       UIDeviceOrientationLandscapeLeft == toInterfaceOrientation)
    {
        vertoolBar.hidden = YES;
        hortoolBar.hidden = NO;
    
    }
    else
    {
        hortoolBar.hidden = YES;
        vertoolBar.hidden = NO;
    }
    
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    self.showsCameraControls = YES;
}

-(void)dealloc
{
    [vertoolBar release];
    [vertoolBar release];
    [vBackView  release];
    [hBackView    release];
    [super dealloc];
}

 
@end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值