Note that there are some explanatory texts on larger screens.

plurals
  1. POPushing UITableView to UITableView
    primarykey
    data
    text
    <p>I can't seem to push to the other UITableView. When I run the code, it only displays the EventType and when clicked, it do sent push to the other UITableView, displaying the Events. The code is suppose to push one UITableView to the other UITableView. Please can someone help me to solve this problem I'm having. I think it is coming from the RootViewController but I cant seem to pinpoint where the problem lies.</p> <p>The application is working ok, but I can't push to the other TableViewController. Here is the code used.Here is the code used, but it doesn't really reveal much as most of the set up is done using IB. </p> <p><strong>This is <code>RootViewController.m</code> - I think the problem is coming from this but I can't seem to pinpoint from where.</strong></p> <pre><code>#import "RootViewController.h" #import "EventTypeViewController.h" @interface RootViewController () @end @implementation RootViewController @synthesize eventType; - (void) viewDidLoad { eventType = [[NSMutableArray alloc]init]; [eventType addObject:@"Corporate"]; [eventType addObject:@"Social"]; [eventType addObject:@"Dining"]; [self setTitle: @"Events"]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [eventType count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; cell.textLabel.text = [[eventType objectAtIndex:indexPath.row]retain]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; return cell; } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { EventTypeViewController *events = [[EventTypeViewController alloc] initWithNibName:@"EventTypeViewController" bundle:nil]; if ([[eventType objectAtIndex:indexPath.row] isEqual:@"Corporate"]) { events.eventsInt = 0; [events setTitle:[eventType objectAtIndex:indexPath.row]]; } if ([[eventType objectAtIndex:indexPath.row] isEqual:@"Social"]) { events.eventsInt = 1; [events setTitle:[eventType objectAtIndex:indexPath.row]]; } if ([[eventType objectAtIndex:indexPath.row] isEqual:@"Dining"]) { events.eventsInt = 2; [events setTitle:[eventType objectAtIndex:indexPath.row]]; } [self.navigationController pushViewController:events animated:YES]; } @end </code></pre> <p><strong>This is <code>EventTypeViewController.m</code> - I dont have much to say about it.</strong></p> <pre><code>#import "EventTypeViewController.h" @interface EventTypeViewController () @end @implementation EventTypeViewController @synthesize eventsInt; - (void)viewDidLoad { corporateArray = [[NSMutableArray alloc] initWithObjects:@"Corporate 1", @"Corporate 2", @"Corporate 3", @"Corporate 4", nil]; socialArray = [[NSMutableArray alloc] initWithObjects:@"Social 1", @"Social 2", nil]; diningArray = [[NSMutableArray alloc] initWithObjects:@"Dining 1", @"Dining 2", @"Dining 3", nil]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { #warning Potentially incomplete method implementation. // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (eventsInt == 0) return [corporateArray count]; if (eventsInt == 1) return [socialArray count]; if (eventsInt == 2) return [diningArray count]; [self.tableView reloadData]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]autorelease]; } // Configure the cell... if (eventsInt == 0) cell.textLabel.text = [[corporateArray objectAtIndex:indexPath.row]retain]; if (eventsInt == 1) cell.textLabel.text = [[socialArray objectAtIndex:indexPath.row]retain]; if (eventsInt == 2) cell.textLabel.text = [[diningArray objectAtIndex:indexPath.row]retain]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; return cell; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload