Tuesday, 3 September 2013

View loading before pressing table cell in cocoa

View loading before pressing table cell in cocoa

I where trying to load a view when pressed the cell in nstableview but
view loading before pressing button. Could any one identify my mistake
- (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];
}
}

No comments:

Post a Comment