简单的表格导航帮助

发布于 2024-11-08 11:07:28 字数 1333 浏览 0 评论 0原文


我的视图是导航控制器内的表格视图。我使用其他人的代码来执行此操作,并且我知道这是该人编写代码时的意图,但是当我触摸表格单元格时,它会将我带到相同的视图。您如何评价下面的代码以使用每个不同的表格单元加载不同的笔尖。

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 sharedApplication] delegate];
[delegate.moreNavController pushViewController:aboutDetailViewController animated:YES];

}

我必须执行 if 语句吗?如果是的话我该怎么写代码。我需要这里能得到的所有帮助。 感谢您的帮助。

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 sharedApplication] 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

允世 2024-11-15 11:07:28
-(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;
       }
}
-(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;
       }
}
万人眼中万个我 2024-11-15 11:07:28
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)
{

}

好吧......

你必须在下面的方法中写下所有这些东西

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
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 {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文