Xcode PopOver - 跨文件功能使用?
我的项目中有一个 UIPopoverController 。
文件组成
Mainfile.h 主文件.m Mainfile.xib (VIEW)
tableview.h 表格视图.m tableview.xib(表视图)
我将 PopoverController 的方法放在我的主文件中。我的问题是当我选择表中的一行时,我无法访问从 mainfile.m 到 tableview.m 的方法。
我的代码
Mainfile.h
UIPopoverController *popMenu;
@property(nonatomic,retain) IBOutlet UIPopoverController *popMenu;
-(IBAction)showPopOverid) sender;
-(IBAction)hidePopOver;
Mainfile.m
#import "tableview.h"
-(IBAction)showPopOverid) sender {
if ([popMenu isPopoverVisible]) {
[popMenu dismissPopoverAnimated:YES];
} else {
tableview *toc = [[tocView alloc] init];
popMenu = [[UIPopoverController alloc] initWithContentViewController:toc];
[toc release];
[popMenu presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAn y animated:YES];
}
}
-(IBAction)hidePopOver {
NSLog(@"hidePopOver");
[popMenu dismissPopoverAnimated:YES];
}
在其他文件
tableview.m
- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {
//I WANT TO ACCESS THE METHOD of hidePopOver from the mainfile so i can hide my popViewController
// i've tried a lot but not working
NSLog(@"hidePopOver");
}
提前谢谢你们
I have a UIPopoverController in my project.
File composition
Mainfile.h
Mainfile.m
Mainfile.xib (VIEW)
tableview.h
tableview.m
tableview.xib (TABLE VIEW)
i put my method for my PopoverController in my mainfile. My problem is i cannot access my method from mainfile.m to tableview.m when i select a row in a table.
My code
Mainfile.h
UIPopoverController *popMenu;
@property(nonatomic,retain) IBOutlet UIPopoverController *popMenu;
-(IBAction)showPopOverid) sender;
-(IBAction)hidePopOver;
Mainfile.m
#import "tableview.h"
-(IBAction)showPopOverid) sender {
if ([popMenu isPopoverVisible]) {
[popMenu dismissPopoverAnimated:YES];
} else {
tableview *toc = [[tocView alloc] init];
popMenu = [[UIPopoverController alloc] initWithContentViewController:toc];
[toc release];
[popMenu presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAn y animated:YES];
}
}
-(IBAction)hidePopOver {
NSLog(@"hidePopOver");
[popMenu dismissPopoverAnimated:YES];
}
in other file
tableview.m
- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {
//I WANT TO ACCESS THE METHOD of hidePopOver from the mainfile so i can hide my popViewController
// i've tried a lot but not working
NSLog(@"hidePopOver");
}
Thank you in advance guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你有一个
ParentViewController
和一个childViewControllerPopover
用于某些按钮上的弹出窗口,上面有一个“childViewController”!使用这样的吹气代码,
要关闭您的
childViewControllerPopover
,您可以首先在ChildViewController.h
中当选择
yourTable
的一个cell
时!您应该调用该方法,因此请将其放入ChildViewController.m
和您的
ParnetViewController.h
以及
ParnetViewController.m
I suppose you have a
ParentViewController
and achildViewControllerPopover
for popover on some button and a 'childViewController' on it!For closing your
childViewControllerPopover
you can use such a blow codeFirst in
ChildViewController.h
When one
cell
ofyourTable
selected! you should call that method, so put this inChildViewController.m
And in your
ParnetViewController.h
And for
ParnetViewController.m
看起来您需要使用委托来调用其他方法。 Xcode 没有全局控制器,可以让您在其他类方法不是程序的焦点时调用它们。
It looks like you need to use a delegate to call the other method. Xcode doesn't have a global controller that lets you call other class methods when they aren't the focus of the program.