table views in a segmented controller

Discussion in 'iOS Programming' started by ljg93, Aug 28, 2011.

  1. ljg93, Aug 28, 2011
    Last edited: Aug 28, 2011

    ljg93 macrumors member

    Joined:
    Mar 13, 2011
    #1
    I am trying to make different table views appear on a view when a user pushes a button on a segmented controller my approach was to create two different instances for each table and then hide one of the tables when a user presses a button. my code below compiles but no table appears on my simulator.

    heres my header and .m files

    Code:
    
    
    
    #import <UIKit/UIKit.h>
    
    
    @interface SettingsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
    {
    	UITableView *ivMainTableView;
    	NSMutableArray *ivContentsList;
        
        UITableView *secondTableView;
    	NSMutableArray *secondContentsLists;
        UIView				*currentTable;
    
        
        
        
    	UISwitch				*switchCtl;
        UISegmentedControl	*buttonBarSegmentedControl;
    
    }
    
    // Properties
    @property (nonatomic, retain, readonly) UISwitch *switchCtl;
    @property (nonatomic, retain) IBOutlet UITableView *mainTableView;
    @property (nonatomic, retain) NSMutableArray *contentsList;
    @property (nonatomic, retain) IBOutlet UISegmentedControl *buttonBarSegmentedControl;
    
    
    @property (nonatomic, retain) IBOutlet UITableView *secondTableView;
    @property (nonatomic, retain) NSMutableArray *secondContentsLists;
    @property (nonatomic, retain) UIView *currentTable;
    
    
    
    
    
    
    - (IBAction)togglePickers:(id)sender;		// for changing between UIPickerView, UIDatePickerView and custom picker
    
    
    
    // Notification Handlers
    
    
    // UI Response
    
    
    // Other
    
    
    
    @end
    
    



    Code:
    
    
    
    
    //
    //  ArrayViewController.m
    //  SlickArraySectionTableViews
    //
    //  Created by Brian Slick on 2/2/11.
    //  Copyright 2011 BriTer Ideas LLC. All rights reserved.
    //
    
    #import "SettingsViewController.h"
    
    
    // Models and other global
    
    // Sub-controllers
    
    @implementation SettingsViewController
    
    #pragma mark -
    #pragma mark Synthesized Properties
    
    @synthesize mainTableView = ivMainTableView;
    @synthesize contentsList = ivContentsList;
    @synthesize switchCtl;
    @synthesize buttonBarSegmentedControl;
    
    @synthesize secondTableView; 
    @synthesize secondContentsLists; 
    @synthesize currentTable;
    
    #pragma mark -
    #pragma mark Dealloc and Memory Methods
    
    - (CGRect)pickerFrameWithSize:(CGSize)size
    {
    	CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
    	CGRect pickerRect = CGRectMake(	0.0,
                                       screenRect.size.height - 42.0 - size.height,
                                       size.width,
                                       size.height);
    	return pickerRect;
    }
    
    
    - (void)didReceiveMemoryWarning
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
        [super didReceiveMemoryWarning];
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    }
    
    - (void)setView:(UIView *)aView
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
        if (!aView)			// view is being set to nil
    	{ 
    		
        }
    	
        [super setView:aView];
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    }
    
    
    
    
    #pragma mark -
    #pragma mark Custom Getters and Setters
    
    #pragma mark -
    #pragma mark Initialization and UI Creation Methods
    
    - (id)init
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    	return [self initWithNibName:nil bundle:nil];
    }
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    	if (self)
    	{
    	}
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    	return self;
    }
    
    #pragma mark -
    #pragma mark UIViewController Methods
    
    
    
    - (void)createMain
    
    {
        self.mainTableView.backgroundColor = [UIColor whiteColor];
    	
    	NSArray *firstSection = [NSArray arrayWithObjects:@"Local Weather", @"Our Menu",@"Hotel Entertainment", nil];
    	NSArray *secondSection = [NSArray arrayWithObjects:@"Map",@"Hotel History",@"Dining Room",@"Hotel Bars",@"Book Now",@"Swimming Pool", nil];
    	NSArray *thirdSection = [NSArray arrayWithObjects:@"About",@"Bouncing Beers", nil];
    	
    	NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:firstSection, secondSection, thirdSection, nil];
        
        
    	[self setContentsList:array];
    	[array release], array = nil;
        
    	// position the picker at the bottom
    	ivMainTableView = [[UITableView alloc] initWithFrame:CGRectZero];
    	
    	ivMainTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
    	CGSize pickerSize = [ivMainTableView sizeThatFits:CGSizeZero];
    	ivMainTableView.frame = [self pickerFrameWithSize:pickerSize];
        
    	
    	// this view controller is the data source and delegate
    	ivMainTableView.delegate = self;
    	ivMainTableView.dataSource = self;
    	
    	// add this picker to our view controller, initially hidden
    	ivMainTableView.hidden = NO;
    	[self.view addSubview:ivMainTableView];
    }
    
    - (void)createTwo
    {
        
        self.secondTableView.backgroundColor = [UIColor redColor];
        
        NSArray *firstsSection = [NSArray arrayWithObjects:@"Local GEIGER", @"Our Menu",@"Hotel Entertainment", nil];
    	NSArray *secondsSection = [NSArray arrayWithObjects:@"Map",@"Hotel History",@"Dining Room",@"Hotel Bars",@"Book Now",@"Swimming Pool", nil];
    	NSArray *thirdsSection = [NSArray arrayWithObjects:@"About",@"Bouncing Beers", nil];
    	
    	NSMutableArray *arrays = [[NSMutableArray alloc] initWithObjects:firstsSection, secondsSection, thirdsSection, nil];
        
        
    	[self setSecondContentsLists:arrays];
    	[arrays release], arrays = nil;
        
    	secondTableView = [[UITableView alloc] initWithFrame:CGRectZero];
    	
    	secondTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
        
    	CGSize pickerSize = [secondTableView sizeThatFits:CGSizeZero];
    	secondTableView.frame = [self pickerFrameWithSize:pickerSize];
        
    	
    	// this view controller is the data source and delegate
    	secondTableView.delegate = self;
    	secondTableView.dataSource = self;
    	
    	// add this picker to our view controller, initially hidden
    	secondTableView.hidden = NO;
    	[self.view addSubview:secondTableView];
    }
    
    
    - (void)showPicker:(UIView *)picker
    {
    	// hide the current picker and show the new one
    	if (currentTable)
    	{
    		currentTable.hidden = YES;
    	}
    	currentTable.hidden = NO;
    	
    	currentTable = picker;	// remember the current picker so we can remove it later when another one is chosen
    }
    
    - (IBAction)togglePickers:(id)sender
    {
    	UISegmentedControl *segControl = sender;
    	switch (segControl.selectedSegmentIndex)
    	{
    		case 0:	// UIPickerView
    		{
           
    			[self showPicker:ivMainTableView];
    			break;
    		}
    		case 1: // UIDatePicker
    		{	
    			// start by showing the time picker
    			
    			// initially set the picker style to "date" format
    		
    			[self showPicker:secondTableView];
                
    			break;
    		}
    			
                
    	}
    }
    
    
    - (void)viewDidLoad
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
        [super viewDidLoad];
        self.title = NSLocalizedString(@"Information", @"Information");
        
        
        
    	[self createMain];	
    	[self createTwo];
        
        
        
        //self.mainTableView.backgroundColor = [UIColor clearColor];
        
        
    }
    - (void)dealloc
    {
    	
    	[buttonBarSegmentedControl release];
    	
    	[super dealloc];
    }
    
    
    - (void)viewDidUnload
    {
    	[super viewDidUnload];
    	
    	// release and set out IBOutlets to nil
    	self.buttonBarSegmentedControl = nil;
    	
    	// release all the other objects
    
    	
    
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    	// we support rotation in this view controller
    	return YES;
    }
    
    
    - (void)viewDidAppear:(BOOL)animated
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	[super viewDidAppear:animated];
    	
    	
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    }
    
    - (void)viewWillDisappear:(BOOL)animated
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	[super viewWillDisappear:animated];
    	
    	
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    }
    
    - (void)viewDidDisappear:(BOOL)animated
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	[super viewDidDisappear:animated];
    	
    	
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    }
    
    
    
    #pragma mark -
    #pragma mark Notification Handlers
    
    
    
    #pragma mark -
    #pragma mark UI Response Methods
    
    
    
    #pragma mark -
    #pragma mark Misc Methods
    
    
    #pragma mark -
    #pragma mark UITableView Datasource Methods
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	NSInteger sections = [[self contentsList] count];
        
        NSInteger sectionsT = [[self secondContentsLists] count];
    
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    	return sections;
        return sectionsT;
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        self.mainTableView.sectionHeaderHeight = 40;
        NSString *title = nil;
        // Return a title or nil as appropriate for the section.
        
        switch (section) {
            case 0:
                title = @"Hotel Information";
                break;
            case 1:
                title = @"On the Go Information";
                break;
            case 2:
                title = @"Our Website";
                break;
            default:
                break;
        }
        
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)];
        
        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0,0, tableView.bounds.size.width - 1,26)] autorelease];
        label.text = title;
        label.textColor =  [UIColor colorWithPatternImage:[UIImage imageNamed:@"section_bar_green.png"]];
        
        label.font = [UIFont fontWithName:@"Futura" size:16];
        label.backgroundColor =  [UIColor clearColor];
        
        [v addSubview:label];
        // [UIColor colorWithPatternImage:[UIImage imageNamed:@"section_bar_green.png"]];;
        return v;
    }
    
    - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
    	return 27.0;
    }
    
    
    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
        self.mainTableView.sectionHeaderHeight = 40;
        NSString *title = nil;
        // Return a title or nil as appropriate for the section.
        
        switch (section) {
            case 0:
                title = @"Here is some information that is useful to every guest!";
                break;
            case 1:
                title = @"Check out some of this important information regarding this hotel";
                break;
            case 2:
                title = @"Click to see what future updates will hold and when they will be released";
                break;
            default:
                break;
        }
        
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)];
        
        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0,0, tableView.bounds.size.width - 1,26)] autorelease];
        label.text = title;
        label.textColor = [UIColor whiteColor];
        
        label.font = [UIFont fontWithName:@"Futura" size:10];
        label.backgroundColor =  [UIColor clearColor];
        
        [v addSubview:label];
        // [UIColor colorWithPatternImage:[UIImage imageNamed:@"section_bar_green.png"]];;
        return v;
    }
    
    - (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    {
    	return 27.0;
    }
    
    
    
    
    
    - (NSInteger)tableView:(UITableView *)tableView
     numberOfRowsInSection:(NSInteger)section
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	NSArray *sectionContents = [[self contentsList] objectAtIndex:section];
    	NSInteger rows = [sectionContents count];
        
        NSArray *sectionTContents = [[self secondContentsLists] objectAtIndex:section];
    	NSInteger rowsT = [sectionTContents count];
    	
    	
    	NSLog(@"rows is: %d", rows);
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    	return rows;
        return rowsT;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView
    		 cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	NSArray *sectionContents = [[self contentsList] objectAtIndex:[indexPath section]];
    	NSString *contentForThisRow = [sectionContents objectAtIndex:[indexPath row]];
        
        NSArray *sectionTContents = [[self secondContentsLists] objectAtIndex:[indexPath section]];
    	NSString *contentTForThisRow = [sectionTContents objectAtIndex:[indexPath row]];
    	
    	static NSString *CellIdentifier = @"CellIdentifier";
    	
    	
    	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    	if (cell == nil)
    	{
    		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    	}
    	
    	//NSUInteger row =[indexPath row];
    	//NSUInteger section = [indexPath indexAtPosition:0];
    	
    
    	
    	
    	[[cell textLabel] setText:contentForThisRow];
    	
    	if ([cell.textLabel.text isEqualToString:@"Local Weather"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"weather.png"]];
    		cell.detailTextLabel.text = @"Weather";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17];
    	}
        if ([cell.textLabel.text isEqualToString:@"Map"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"weather.png"]];
    		cell.detailTextLabel.text = @"Weather";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17];
    	}
    	
    	if ([cell.textLabel.text isEqualToString:@"Our Menu"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"menu.png"]];
    		cell.detailTextLabel.text = @"Menu";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
    	
    	if ([cell.textLabel.text isEqualToString:@"Hotel Entertainment"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"entertain.png"]];
    		cell.detailTextLabel.text = @"Fun";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
    	
    	if ([cell.textLabel.text isEqualToString:@"Hotel History"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"history.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
    	if ([cell.textLabel.text isEqualToString:@"Dining Room"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"dining.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
        if ([cell.textLabel.text isEqualToString:@"Hotel Bars"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"bar.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
        if ([cell.textLabel.text isEqualToString:@"Book Now"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"book now.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
        if ([cell.textLabel.text isEqualToString:@"Swimming Pool"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"pool.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
        if ([cell.textLabel.text isEqualToString:@"About"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"banner.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
        if ([cell.textLabel.text isEqualToString:@"Bouncing Beers"]) {
    		[cell.imageView setImage:[UIImage imageNamed:@"NBall.png"]];
    		cell.detailTextLabel.text = @"";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.font = [UIFont fontWithName:@"Futura" size:17];
            cell.detailTextLabel.font = [UIFont fontWithName:@"Futura" size:17]; 
    	}
    	
    /*
    	if ([cell.textLabel.text isEqualToString:@"Push"]) {
    		//[cell.imageView setImage:[UIImage imageNamed:@"aboutusicon.png"]];
    		cell.detailTextLabel.text = @"Time";
    		cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    	}
     */
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    	return cell;
    }
    
    #pragma mark -
    #pragma mark UITableView Delegate Methods
    
    - (void)tableView:(UITableView *)tableView
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	
    	
    	
    	NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    	
    	[tableView deselectRowAtIndexPath:indexPath animated:YES];
    	NSMutableString *workoutName = [NSMutableString string];
    	[workoutName setString:[[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]];
    	[workoutName replaceOccurrencesOfString:@" " withString:@"" options:0 range:NSMakeRange(0, [workoutName length])];
    	[workoutName appendFormat:@"ViewController"];
    	
    	id newViewController = [[objc_getClass([workoutName cStringUsingEncoding:NSUTF8StringEncoding]) alloc] init];
    	[self.navigationController pushViewController:newViewController animated:YES];
    	
    
    	
    	
    	
    	
    	
    	NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    	
    	
    }
    
    
    @end
    
    
    
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Apply a basic debugging principle: confirm your expectations.

    For example, you already have NSLog()'s in a bunch of methods. When these appear, you are confirming that execution is actually reaching that point. Sadly, you haven't posted any of the output, so no one else can confirm what's happening.

    You also aren't doing any other kind of NSLog() confirmation in any of those methods. For example, you could confirm that the necessary array is non-nil, and actually contains the expected objects. You could confirm that the number of sections being returned isn't 0.

    Perhaps you're using the debugger and stepping through your table-view methods. If so, then what does the debugger tell you the values of important variables are?

    Debugging isn't magic. The basics don't take immense skill or training, either. At it's most fundamental, it's just looking to see that what you think is happening is really happening (confirming expectations). Your use of NSLog() shows that you know how to look at things. Next, you have to add NSLog statements that look at the right things at the right times. Then you have to confirm that what you see is what you expect.

    Also see my posts in this other thread:
    http://forums.macrumors.com/showthread.php?t=1218435


    You also have a logical problem: you won't be able to make a single object (the controller) be the data-source and delegate for two separate table-views, unless you use the tableView parameter to switch between the two distinct sets of behavior. You're not currently doing this, so the behavior for all table-views is going to end up being the same.

    From a design standpoint, it's usually a bad idea to make a single object be the data-source and delegate for multiple different table-views. This is because you have to add conditional logic (if/else) to every delegate or data-source method. You're almost always better off having a separate class, and a separate instance of that class, serving as the delegate and data-source for each separate view.
     
  3. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #3
    Ok I had a little hard time following the first few paragraphs of your answer but thanks. I had to take out a bunch of the NS logs because my post would not fit with all of them!

    So what your saying is to create a new delegate and datasource for the other tableview (secondTableView). How would I go about doing that?
     
  4. PhoneyDeveloper, Aug 28, 2011
    Last edited: Aug 28, 2011

    PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    I can't read all the code in detail but you might want to make sure the frames of your tables make them big enough to be seen.

    Also, you might want to make one table view work before working on the second table view.

    Also, it's rude to post the same question to multiple forums at the same time.
     
  5. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #5
    also do you have any idea why nothing appears at all?
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    How are we supposed to know that? You didn't say that in your post. We can't read your mind, and we can't possibly see the code you didn't post.

    At minimum, you should answer this question: What have you tried?

    Clearly, part of the answer is going to be "I put in a bunch of NSLog's", but you need to be very specific. Post the actual code. Post the actual output from the NSLog's. Describe what you expected to see in the output.

    If the code or output is too long to post here, then either make your example smaller (a good idea anyway), or post it someplace like pastebin.com and then post the URL here.


    I can tell from the code you've posted that your basic coding strategy isn't to start small and work your way up. Frankly, that strategy would probably be a good one to apply.

    Start with the simplest table-view app that works. It doesn't have to be complete, or even look anything like your final intention, but it must work. If it doesn't work, then either simplify it so it does work, or start from a known-working example such as Apple's sample code.

    Once you have something that works, modify it one step at a time. Make sure it still works after every step. If it stops working, then stop modifying it and fix the thing that doesn't work. Do not continue modifying if it doesn't work.

    If it remains simple and stops working, then post the code that doesn't work, along with the changes you made from the prior working code.


    The usual way: write a new class that implements the protocols.

    What other apps have you written?

    What tutorials or books have you read to reach this point?

    What example apps have you built, run, or modified?
     

Share This Page