开发者

Simple Table Navigation Help

开发者 https://www.devze.com 2023-03-07 04:54 出处:网络
Hi My view is a table view inside a navigation controller. I used someone else\'s code to do this, and i know this was the person\'s intention when writing the code, but when I touch a table cell it b

Hi

My view is a table view inside a navigation controller. I used someone else's code to do this, and i know this was the person's intention when writing the code, but when I touch a table cell it brings me to the same view. How would you critique the code below to load a different nib with each different table cell.

MoreTableViewController.h

@interface MoreTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *moreTableView;
NSMutableArray *moreArray;
AboutDetailViewController *aboutDetailViewController;

}

@property (nonatomic, retain) NSMutableArray *moreArray;
@property (nonatomic, retain) AboutDetailViewController *aboutDetailViewController;
@end

MoreTableViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
if (self.aboutDetailViewController == nil) {
    AboutDetailViewController *aboutD = [[AboutDetailViewController alloc] initWithNibName:@"AboutDetailViewController" bundle:nil];
    self.aboutDetailViewController = aboutD;
    [aboutD release];

}
aboutDetailViewController.title = [NSString stringWithFormat:@"%@", [moreArray objectAtIndex:row]];

ROSS_APP_7AppDelegate *delegate = [[UIApplication sharedApp开发者_C百科lication] delegate];
[delegate.moreNavController pushViewController:aboutDetailViewController animated:YES];

}

Would i have to do an if statement? If so, how would I write the code. I need all the help I can get here. Thanks For your help.


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger row = [indexPath row];
        switch(row) {
          case 0:
          // First row
          // Push xib
          break;

          case 1:
          // Second row
          // Push xib
          break;
       }
}


if(indexPath.row == 0)
{
    AboutDetailViewController *aboutD = [[AboutDetailViewController alloc] initWithNibName:@"AboutDetailViewController" bundle:nil];
    self.aboutDetailViewController = aboutD;
    [aboutD release];
}
else if(indexPath.row == 1)
{

}
else if(indexPath.row == 2)
{

}

Ok....

And you have to write all these things in below method

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号