我在我的应用中使用size_t alphabet = sizeof(mangMaHoa) / sizeof(mangMaHoa[0]);
,每当我点击第二次取消并显示以下崩溃日志时它就会崩溃:
由于未捕获的异常而终止应用 ' UIViewControllerHierarchyInconsistency',原因:'子视图 控制器:应该有父 view controller :( null)但实际的父级是:'
解雇代码:
private void UpdateTotalBill()
{
double vat = 0;
double TotalPrice = 0;
long TotalProducts = 0;
foreach (DataListItem item in dlCartProducts.Items)
{
Label PriceLabel = item.FindControl("lblPrice") as Label; // get price
TextBox ProductQuantity = item.FindControl("txtProductQuantity") as TextBox; // get quantity
double ProductPrice = Convert.ToInt64(PriceLabel.Text) * Convert.ToInt64(ProductQuantity.Text); //computation fro product price. price * quantity
vat = (TotalPrice + ProductPrice) * 0.12; // computation for vat
Math.Round(vat, 2);
TotalPrice = TotalPrice + ProductPrice;
TotalProducts = TotalProducts + Convert.ToInt32(ProductQuantity.Text);
}
Label1.Text =Convert.ToString(vat);
txtTotalPrice.Text = Convert.ToString(TotalPrice + 40 + vat); // add vat + 40 delivery charge to total price
txtTotalProducts.Text = Convert.ToString(TotalProducts);
}
相同的代码在其他应用程序中运行正常但是当我将代码复制到新项目时,崩溃正在重复发生。 它发生在iOS 8.3& 7.1,未在其他版本上测试过。 任何帮助都会非常明显。
答案 0 :(得分:0)
在.h
@interface YourViewController : UIViewController < UIImagePickerControllerDelegate, UINavigationControllerDelegate>
如果要打开图像选择器,请将其初始化。
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.allowsEditing = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imgPicker animated:YES completion:^{ }];
委托方法
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
}