我正在做一个项目,我正在尝试使用这个框架VPPDropdown
但我希望它与storyboard
.
那我做了什么?UITableviewController
我在屏幕上拖了一个。然后在我的代码中我有这个。
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
_dropDownSelection = [[VPPDropDown alloc] initSelectionWithTitle:@"Selection Combo"
tableView:self.tableView
indexPath:[NSIndexPath indexPathForRow:kRowDropDownSelection inSection:kSection1]
delegate:self
selectedIndex:1
elementTitles:@"Option 1", @"Option 2", @"Option 3", nil];
_dropDownDisclosure = [[VPPDropDown alloc] initDisclosureWithTitle:@"Disclosure Combo"
tableView:self.tableView
indexPath:[NSIndexPath indexPathForRow:kRowDropDownDisclosure inSection:kSection1]
delegate:self
elementTitles:@"Disclosure 1", @"Disclosure 2", @"Disclosure 3", @"Disclosure 4", @"Disclosure 5", nil];
NSMutableArray *elts = [NSMutableArray array];
for (int i = 1; i <= 4; i++) {
// just some mock elements
VPPDropDownElement *e = [[VPPDropDownElement alloc] initWithTitle:[NSString stringWithFormat:@"Element %d",i] andObject:[NSNumber numberWithInt:i]];
[elts addObject:e];
}
_dropDownCustom = [[VPPDropDown alloc] initWithTitle:@"Custom Combo"
type:VPPDropDownTypeCustom
tableView:self.tableView
indexPath:[NSIndexPath indexPathForRow:kRowDropDownCustom inSection:kSection2]
elements:elts
delegate:self];
}
return self;
}
经过一番研究,我发现当你使用 a UITableViewController
inside a时storyboard
。上面的方法没有被调用。并且您应该将该代码放入:
-(id)initWithCoder:(NSCoder *)aDecoder {
if ( !(self = [super initWithCoder:aDecoder]) ) return nil;
// Your code goes here!
return self;
}
当我这样做时,我收到以下错误
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/stefgeelen/Library/Application Support/iPhone Simulator/6.1/Applications/6D0EF4BF-068C-493C-A1A5-CFAA2B935D56/claesdistribution.app> (loaded)' with name 'DR7-d0-mee-view-dDq-is-22f''
有人可以帮我解决这个问题吗?