iPad / iPhone TableVIew帮助推动新观点

时间:2010-08-04 13:59:00

标签: iphone ipad ios4

所以我们最近开始为我们公司开发iPad应用程序。不幸的是,我们这里没有人做过任何iPhone / iPad的开发,所以我们只是在飞行中学习它并实现它。基本上,当我们尝试在单击表格行时将视图推送到屏幕上时,我们的问题就出现了。我们都不知道为什么它没有这样做,因为代码看起来100%正确我们可以告诉。这是didRowSelectedAtIndex:方法的样子:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic -- create and push a new view controller

 if(pdvController == nil)
  pdvController = [[PersonDetailViewController alloc] initWithNibName:@"PersonDetailView" bundle:[NSBundle mainBundle]];

 Person *aPerson = [appDelegate.people objectAtIndex:indexPath.row];

 pdvController.aPerson = aPerson;

 [self.appDelegate.navigationController pushViewController:pdvController animated:YES];
}

,这是toolbarSearchViewController的标题:

  #import <UIKit/UIKit.h>

    #import "RecentSearchesController.h"
    #import "PersonDetailViewController.h"

    @class ToolbarSearchAppDelegate, PersonDetailViewController;

    @interface ToolbarSearchViewController : UIViewController <UISearchBarDelegate, UIPopoverControllerDelegate, RecentSearchesDelegate> {

     ToolbarSearchAppDelegate *appDelegate;

        UIToolbar *toolbar;
        UISearchBar *searchBar;
     UITableView *resultsTable;

        PersonDetailViewController *pdvController;
        RecentSearchesController *recentSearchesController;

     UITableViewController *resultsTableController;
        UIPopoverController *recentSearchesPopoverController; 

    }


    @property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
    @property (nonatomic, retain) UISearchBar *searchBar;
    @property (nonatomic, retain) IBOutlet UITableView *resultsTable;

    @property (nonatomic, retain) ToolbarSearchAppDelegate *appDelegate;
    @property (nonatomic, retain) PersonDetailViewController *pdvController;
    @property (nonatomic, retain) UITableViewController *resultsTableController;
    @property (nonatomic, retain) RecentSearchesController *recentSearchesController;
    @property (nonatomic, retain) UIPopoverController *recentSearchesPopoverController;



    @end

和ToolbarSearchAppDelegate标题:

#import <UIKit/UIKit.h>

@class ToolbarSearchViewController;

@interface ToolbarSearchAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    ToolbarSearchViewController *viewController;
 UINavigationController *navigationController;


 NSMutableArray *people;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet ToolbarSearchViewController *viewController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@property (nonatomic, retain) NSMutableArray *people;

@end

最后是personDetailController.h:

#import <UIKit/UIKit.h>

@class Person;

@interface PersonDetailViewController : UIViewController {

 IBOutlet UITableView *tableView;

 Person *aPerson;
}

@property (nonatomic, retain) Person *aPerson;
@property (nonatomic, retain) UITableView *tableView;

@end

我们非常恼火,因为我们都不知道为什么它没有加载,你们提供的任何帮助或见解都会令人惊叹。我不确定你可能需要看什么,所以如果你需要更具体的东西,请告诉我,我会发布它。谢谢!

PS。我不确定代码标记将如何处理所有Obj-c的古怪语法,因此如果您看到语法错误,请忽略它们。假设它在语法上是正确的,并将编译并运行...

1 个答案:

答案 0 :(得分:1)

这条线看起来有点奇怪:

[self.appDelegate.navigationController pushViewController:pdvController animated:YES];

尝试制作

[self.navigationController pushViewController:pdvController animated:YES];

编辑求和操作,问题是您没有导航控制器,因此无法像这样推送视图控制器。您可以做的是,使用

推送视图控制器模态
[self presentModalViewController:pdvController animated:YES];