见user167 ..你只需要创建新的,UITableViewcontroller
例如DropDwnLevel1TableViewController.h
,正确的。DropDwnLevel1TableViewController.m
xib
现在在DropDwnLevel1TableViewController
Create IBOutlate 中设置UITableVIew
一个 UITableView 来nib
连接IBOUTLATE
和设置Delegate
dataSource
现在您可以将创建TableViewController
的添加设置到您UIPopoverViewcontroller
喜欢的以下方法中:-
-(IBAction)btnTableMenu_TouchUpInside:(id)sender{
DropDwnLevel1TableViewController *firstViewCtrl = [[DropDwnLevel1TableViewController alloc] init];
firstViewCtrl.title=@"My tableView";
UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:firstViewCtrl];
[firstViewCtrl contentSizeForViewInPopover];
myPopOVer = [[UIPopoverController alloc] initWithContentViewController:navbar];
[navbar release];
myPopOVer.delegate = self;
myPopOVer.popoverContentSize =CGSizeMake(250,200);
[myPopOVer presentPopoverFromRect:sender.frame inView:sender.superview permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
}
FOR 关闭 popOver
在你声明popOverViewcontroller
.m
文件ViewDidLoad
方法的类中
- (void)viewDidLoad
{
// Hear creating NSNotificationCenter for dismiss popover
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(DismissPopOver:)
name:@"Dismiss"
object:nil];
[super viewDidLoad];
}
-(void)DismissPopOver:(NSNotification *)notification {
[yourPopOVer dismissPopoverAnimated:YES];
}
现在在DropDwnLevel1TableViewController.m
didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// hear call NSNotificationCenter who creating in main class
[[NSNotificationCenter defaultCenter] postNotificationName:@"Dismiss" object:self];
}