当用户按下NSTableView
单元格中的按钮时,我正在尝试加载视图,但在按下按钮之前加载了视图。谁能指出我的错误?
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
_homearray = [NSArray arrayWithObjects:@"Inbox",
@"SentItems",
@"Notifications",
@"Search",
@"Upgrade",
@"Logout", nil];
[self.tableView reloadData];
[self.tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:0]
byExtendingSelection:NO];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return [_homearray count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
return [_homearray objectAtIndex:rowIndex%[_homearray count]];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
if(self.tableView.selectedRow==0)
{
self.second = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
self.second.view.frame = CGRectMake(100, 200, 300, 250);
[self.window.contentView addSubview:self.second.view];
}
}