我有这样的问题:
我想在警报视图中显示自定义视图.所以我创建了一个单独的xib文件并设计了我的接口.并为它实现了类.但是当我应用下面的代码时,它给了我一个错误.
这是代码:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm your Action"
message:@"Click OK to confirm"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel",nil];
NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"customDialogViewController" owner:self options:nil];
customDialogViewController *myView = (customDialogViewController*) [subviewArray objectAtIndex:0];
[alert setValue:myView forKey:@"accessoryView"];
//alert.alertViewStyle = UIAlertViewStylePlainTextInput;
alert.tag = KAlertViewthree;
[alert show];
Run Code Online (Sandbox Code Playgroud)
这是我的错误:
Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<ScheduleView: 0x8adf1a0> should have parent view controller:<_UIModalItemAccessoryViewControllerForLegacyAlert: 0xa888b70> but actual parent is:<UINavigationController: 0x8add8c0>'
Run Code Online (Sandbox Code Playgroud)
我真的很喜欢iOS开发.我做错了吗?哪里出错了?我不知道这个Nib文件在这里说什么"loadNibNamed:@bla boa"我只是给了我的xib名称.任何人都可以给我一个更好的方法来做到这一点,或者你能告诉我在哪里需要改变以解决这个问题?
请指导一下..谢谢.