Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 18, 2012, 09:38 PM   #1
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Issue with putting a tableview inside a scrollview inside a tab view

I'm experimenting with making an IRC program. If you're not familiar with IRC, you can be multiple channels at once. In the client, you can switch channels (chat rooms) and the chat log as well as the nick list (the list of other people in the channel) will reflect what is in your current channel.

I decided to put each channel in it's own tab view. Then as an exercise, I made the tabview tabless, and put some nsbuttons at the top of the window so you can switch between channels.

I made the nick list on the right side of the screen scrollable, since some channels have hundreds of participants. I made a mockup of the user interface, and you can enter the name of a channel and click the + button, and it will 'create' that channel. It adds a button for the tab, a textview for the chat, and an scrollview with a tableview inside for the nick list.

Here's my problem. I create a channel when the program begins. It appears fine. But when I add a new channel, it doesn't work! I can switch back to the first channel, and it appears right.

This is what the first tab looks like, and what I want the others to look like:


Code:
        [[newTab view] addSubview:newChannel.nickScrollView];
        [[newTab view] addSubview:newChannel.nickList];
Produces this:


Code:
        [newChannel.nickScrollView setDocumentView:newChannel.nickList];
        [[newTab view] addSubview:newChannel.nickScrollView];
Produces this:


If I change the code so that I just add the scrollview and the tableview to the tabview, they both show up. But if I change it to put the table inside the scroll view, it shows up but doesn't draw any columns or data. My datasource methods never get called. I colored the scrollview blue and the tableview gray for debugging purposes.

I'm sure it's something very simple. I have some memory leaks in my code (and probably other issues) but I'm just worried about the scrollview issue for now. My project is attached and if anyone took a look I would appreciate it.
Attached Files
File Type: zip Channels.zip (55.3 KB, 6 views)
robvas is offline   0 Reply With Quote
Old Mar 18, 2012, 09:58 PM   #2
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
I believe when you create a tableview it is already embedded in a scroll view, so you may be doing more than you need to here.
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote
Old Mar 19, 2012, 04:11 PM   #3
robvas
Thread Starter
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Quote:
Originally Posted by Sydde View Post
I believe when you create a tableview it is already embedded in a scroll view, so you may be doing more than you need to here.
I will research the tableview more, the way my code is I don't have any settings for scroll properties on the table view.

I noticed if I added more names to the list, the list shows in the other channels, but only the last couple ones. And I can't scroll up to see the rest.
robvas is offline   0 Reply With Quote
Old Mar 19, 2012, 06:08 PM   #4
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
NsTableView is a subclass of NSView, which defines the method -enclosingScrollView. You could use that method to see if there is a scroll view attached to the table and thence adjust the settings (e.g., autohiding of the scroller). If you log the value and it returns nil, then I would be mistaken.

One way to make this all simple would be to create channel.nib, layout your stuff in a view object, and set FilesOwner to your IRCChannelController object you design, then you can just load nibs for channels, the controller object handling the placement of its view object. One advantage to this is that each channel controller could implement features like notification or automatic tab switching on activity.
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote
Old Mar 19, 2012, 09:09 PM   #5
robvas
Thread Starter
macrumors 68000
 
Join Date: Mar 2009
Location: USA
I figured it out. The tableview kept growing to all kinds of weird sizes when I added it to the tab.

[newChannel.nickScrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];

That was the cuplrit. Ugh!

Quote:
Originally Posted by Sydde View Post
One way to make this all simple would be to create channel.nib, layout your stuff in a view object, and set FilesOwner to your IRCChannelController object you design, then you can just load nibs for channels, the controller object handling the placement of its view object. One advantage to this is that each channel controller could implement features like notification or automatic tab switching on activity.
I'm not sure what I'm going to use for the UI on this program yet - I will probably do at least a test/sample project using nibs for that type of window layout.
robvas is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Map view for inside of stores? mikeej iOS 7 6 Mar 30, 2014 04:01 AM
tablets: Samsung's next Galaxy Tab will have Intel inside, says Reuters AutoUnion39 Alternatives to iOS and iOS Devices 0 May 31, 2013 11:16 AM
Putting G5 inside a Tower PC benstevensuk Mac Pro 44 Mar 18, 2013 05:29 AM
How can I allow the tab key only inside a specific div? sk3pt1c Web Design and Development 13 Feb 12, 2013 08:15 AM
Do you miss street view? It is still available. Instructions inside Dieseldave24v iOS 6 19 Oct 3, 2012 01:54 AM

Forum Jump

All times are GMT -5. The time now is 06:03 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC