使一個新的導航控制器和與所述rootView作爲表呈現它
- (IBAction)seeFavorites{
NSLog(@"Favorites accessed");
if([self.popOverController isPopoverVisible])
{
[self.popOverController dismissPopoverAnimated:YES];
return;
}
UINavigationController *favNav = [[UINavigationController alloc]
initWithRootViewController:favoritesView];
self.popOverController = [[[UIPopoverController alloc]
initWithContentViewController:favNav] autorelease];
[popOverController presentPopoverFromBarButtonItem:revealFavorites permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
favoritesView.view.frame = CGRectMake(10, 10, 310, 320);
favoritesView.title = @"Favorites";
[favoritesView.tableView reloadData];
if (![self.popOverController isPopoverVisible]) {
[favNav release];
}
}
使出口:
在 「文件1」
@class File2;
@interface FirstViewControlleriPad : UIViewController
{
//code
File2 *file2Outlet;
}
@property (nonatomic,retain) IBOutlet File2 *file2Outlet;
@end
在.m文件
#import "File2.h"
@implementation File1
@synthesize file2Outlet
在appDelegate.h
#import "File1.h"
#import "File2.h"
@interface AppDelegate : NSObject {
//...code for appDelegate
File1 *file1;
File2 *file2;
}
@property (nonatomic,retain) File1 *file1;
@property (nonatomic,retain) File2 *file2;
@end
在appDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
file1 = [[File1 alloc]init];
file2 = [[File2 alloc]init];
file1.file2Outlet = file2;
[file1 release];
[file2 release];
我favoritesView是UITableView中的一個實例。 initWithRootViewController正在尋找一個UIViewController的實例嗎? – Crystal
favoritesView是我的其中一個文件的出口。我會更新我的答案以及如何創建出口。 –
完成。希望能幫助到你。其他任何事情都讓我知道 –