简体   繁体   English

iPad / iPhone TableVIew帮助推动新视野

[英]iPad/iPhone TableVIew help pushing a new view

So we have recently started developing applications for the iPad for our company. 因此,我们最近开始为公司开发iPad的应用程序。 Unfortunately none of us here have ever done any iPhone/iPad development so we are just kind of learning on the fly and winging it. 不幸的是,我们这里没有人做过任何iPhone / iPad开发,因此我们只是在不断学习和发展。 Basically our problem is happening when we try to push a view onto the screen when a table row is clicked. 基本上,当我们尝试单击表行时将视图推到屏幕上时,就会发生问题。 Neither of us can figure out why it's not doing it because the code looks 100% correct by anything we can tell. 我们都不知道为什么不这样做,因为根据我们所知,该代码看起来100%正确。 Here is what the didRowSelectedAtIndex: method looks like: 这是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];
}

and here is the header for the toolbarSearchViewController: 这是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

and the ToolbarSearchAppDelegate header: 和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

and finally the personDetailController.h: 最后是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

We are getting pretty annoyed because neither of us can figure out why it's not loading and any help or insight you guys could provide would be amazing. 我们非常恼火,因为我们两个都无法弄清为什么它没有加载,你们提供的任何帮助或见解都将是惊人的。 I wasn't sure what you may need to see, so if you need anything more specific, let me know and I will post it. 我不确定您可能需要看什么,所以如果您需要更具体的信息,请告诉我,我会予以张贴。 Thanks! 谢谢!

ps. ps。 I am not sure how the code tags are going to handle all of Obj-c's quirky syntax, so if you see syntax errors, just ignore them. 我不确定代码标签将如何处理Obj-c的所有古怪语法,因此,如果您看到语法错误,请忽略它们。 Assume that it is syntactically correct and will compile and run... 假设它在语法上是正确的,并且可以编译并运行...

This line looks a little odd: 这行看起来有点奇怪:

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

try and make it 尝试使它

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

edit summing op, the problem is that you don't have a navigation controller, so you can't push a view controller like that. 编辑总结操作,问题在于您没有导航控制器,因此无法像这样推送视图控制器。 What you can do, is pushing a view controller modally , using 可以做的是使用模态推送视图控制器

[self presentModalViewController:pdvController animated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM