我有一个可以画的视图。当用户单击“取消”按钮时,将清除视图并在该视图中绘制新图像。我发布了我的代码。有人可以帮忙吗?
#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 :(得分:0)
听起来你需要在视图上调用setNeedsDisplay :. :)