我是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