2011-06-06 23 views
0

私は描画可能なビューを持っています。ユーザーがキャンセルボタンをクリックすると、ビューがクリアされ、そのビューに新しいImageが描画されます。私は自分のコードを投稿しています。誰も助けることができますか?ビューを削除して再描画する方法

#import "SignatureViewController.h" 


@implementation SignatureViewController 
@synthesize salesToolBar; 



-(void)buttonpressed 
{ 
    NSString *allElements = [myarray componentsJoinedByString:@""]; 
    NSLog(@"%@", allElements);} 


-(void)buttonclear{ 

     [drawImage removeFromSuperview]; 

    //UIGraphicsBeginImageContext(CGSizeMake(self.view.frame.size.height, self.view.frame.size.width));  
    drawImage = [[UIImageView alloc] initWithImage:nil]; 
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)]; 
    drawImage.frame = self.view.frame; 
    [self.view addSubview:drawImage]; 
    self.view.backgroundColor = [UIColor greenColor]; 
    mouseMoved = 0; 
     //[super viewDidLoad]; 

} 

-(void)buttoncancel{ 
    [[self navigationController] popViewControllerAnimated: YES]; 
    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait; 

} 


- (void)viewDidLoad { 
    [super viewDidLoad]; 
    myarray = [[NSMutableArray alloc] init]; 


    CGFloat x = self.view.bounds.size.width/2.0; 
    CGFloat y = self.view.bounds.size.height/2.0; 
    CGPoint center = CGPointMake(y, x); 

    // set the new center point 
    self.view.center = center; 

    CGAffineTransform transform = self.view.transform; 
     transform = CGAffineTransformRotate(transform, -(M_PI/2.0)); 

    self.view.transform = transform; 

    self.view.backgroundColor = [UIColor greenColor]; 
    self.title = @"Signature"; 

    [self createToolbar]; 

    NSLog(@"View Did Load Run"); 


} 

- (void)viewDidAppear:(BOOL)animated { 
    NSLog(@"Self.view.frame.height = %f and width = %f ", self.view.frame.size.height, self.view.frame.size.width); 
    NSLog(@"View Did Appear Run"); 
    self.navigationController.navigationBarHidden=TRUE; 
    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; 



    [super viewDidLoad]; 

} 
+0

何をお手伝いしますか? – Abizern

+0

必要なものをもう少し正確にすることはできますか?この新しい画像はどのように入手できますか?今は「無」と思われる。あなたはそれに 'drawInRect:'メッセージを送ります。このコードにはいくつかのエラーがあります。 –

答えて

0

ビュー上でsetNeedsDisplay:を呼び出す必要があります。 :)

+0

画像はビューに描画された画像です。私の画像ビューはdrawimageと呼ばれています。コード全体を投稿しています。キャンセルボタン以外はすべて修正したと思います。 – user771385

+0

これで、imageviewを含むビューで次の呼び出しを試してみてください... [self.view setNeedsDisplay]; – Luke

+0

私のビューが正しくクリアされていないので、イメージを再描画しようとするとボタンがクリアされた後、画面の一部しか取得されず、最初の時間に画面全体が使用可能になります。私は完全な画面を取得します。 – user771385

関連する問題