我正在尝试在用户按下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];
}
}