【发布时间】:2010-08-05 00:46:36
【问题描述】:
因此,我们最近开始为我们公司开发适用于 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 的所有古怪语法,因此如果您看到语法错误,请忽略它们。假设它在语法上是正确的,并且会编译和运行......
【问题讨论】: