您的位置:首页 > 其它

解决 黑色背景问题

2012-05-09 15:00 405 查看
#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: