我是iOS的新手,我面临着验证视图的问题。我创建签名状观 How to draw Signature on UIView,现在我想通过使用此代码如何检查UIView是否为零或不在客观c
-(IBAction)SavebtnClick:(id)sender
{
if(drawSignView==nil)
{
UIAlertView *alertviewshow =[[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Pease Sign" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertviewshow show];
}
else if (drawSignViewClient==nil)
{
UIAlertView *alertviewshow =[[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Please Sign" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertviewshow show];
}
else
{
viewcontroller1 *management =[[viewcontroller1 alloc] initWithNibName:@"viewcontroller1" bundle:nil];
[self.navigationController pushViewController:management animated:YES];
}
}
做验证,但我没有得到成功。请告诉我我做错了什么。
我想要做验证。
如果我没有签字显示消息。
请给我建议。
在此先感谢!
我保存的图像和使用条件
UIGraphicsBeginImageContext(self.drawSignView.bounds.size);
[[self.drawSignView.layer presentationLayer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// NSData *postData = UIImageJPEGRepresentation(viewImage, 1.0);
// Store the data
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *imageData = UIImageJPEGRepresentation(viewImage, 100);
[defaults setObject:imageData forKey:@"image"];
[defaults synchronize];
if(viewImage==nil)
{
UIAlertView *alertviewshow =[[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Pease Sign" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertviewshow setTag:1];
[alertviewshow show];
}
但它不工作,因为它包含空白图像。
你能告诉更多的代码是什么?这段代码的问题?你想要做什么,详细注明。 –
请为此解释更多... –
这是Signatureview的一个实例吗? – Axel