我有这样的问题:
我想在警报视图中显示自定义视图。所以我创建了一个单独的 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];
这是我的错误:
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>'
我对 iOS 开发真的很陌生。我做错了吗?错在哪里?我不知道这里所说的 Nib 文件是什么“loadNibNamed:@bla boa”,我只是为此给出了我的 xib 名称。谁能给我一个更好的方法来做到这一点,或者你能告诉我我必须在哪里改变才能解决这个问题吗?
请指导我一些..
谢谢。
这个 API 可以解决您的问题,使用它并享受乐趣
https://github.com/Darktt/DTAlertView https://github.com/Darktt/DTAlertView
https://github.com/Scott90/SDCAlertView https://github.com/Scott90/SDCAlertView
https://github.com/lmcd/LMAlertView https://github.com/lmcd/LMAlertView
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)