Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone SDK中popover中Tableview的详细文本_Iphone_Ios_Xcode_Uitableview_Popup - Fatal编程技术网

Iphone SDK中popover中Tableview的详细文本

Iphone SDK中popover中Tableview的详细文本,iphone,ios,xcode,uitableview,popup,Iphone,Ios,Xcode,Uitableview,Popup,我打开一个包含表视图的POP概览。它工作正常,但我的单元格还包含详细文本,当我在popOver中打开表格视图时,在表格视图单元格中看不到这些文本 我的代码如下: -(IBAction)btnTableMenu_TouchUpInside:(id)sender{ ListView *popUp=[[ListView alloc] initWithNibName:@"ListView" bundle:nil]; popoverController = [[UIPopoverContro

我打开一个包含表视图的POP概览。它工作正常,但我的单元格还包含详细文本,当我在popOver中打开表格视图时,在表格视图单元格中看不到这些文本

我的代码如下:

-(IBAction)btnTableMenu_TouchUpInside:(id)sender{

   ListView *popUp=[[ListView alloc] initWithNibName:@"ListView" bundle:nil];



popoverController = [[UIPopoverController alloc]initWithContentViewController:popUp];
popoverController.delegate =self;

[popoverController setPopoverContentSize:CGSizeMake(300, 700)];
[popoverController presentPopoverFromRect:CGRectMake(150,25,20,50) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];


} 

如何解决此问题???

请参见用户167。。您只需要创建新的
UITableViewcontroller
,例如
DropDwnLevel1TableViewController.h
DropDwnLevel1TableViewController.m
xib
右侧

现在在
DropDwnLevel1TableViewController
中创建
UITableVIew
的IBOutlate,在
nib
connect
IBOutlate
中设置一个UITableVIew,并设置
Delegate
dataSource

现在,您可以将创建的
TableViewController
加载项设置到您的
uipooverviewcontroller
中,如下方法:-

-(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];


}
适用于popOVer

在类中,声明
popooverviewcontroller
.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];

}
试试这个:

将观察者添加到您的
popOverController
视图所在的类中

您的
popOverController

yourPopOverControlle.m

-(void)viewdidLoad{

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(removePopover:) name:@"hidePopOver" object:nil];

}
-(void)removePopover:(NSNotification *)notification{
   [yourPopOver  dismissPopoverAnimated:YES];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [[NSNotificationCenter defaultCenter]postNotificationName:@"hidePopOver" object:nil]; 

}
yourTableViewController.m

-(void)viewdidLoad{

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(removePopover:) name:@"hidePopOver" object:nil];

}
-(void)removePopover:(NSNotification *)notification{
   [yourPopOver  dismissPopoverAnimated:YES];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [[NSNotificationCenter defaultCenter]postNotificationName:@"hidePopOver" object:nil]; 

}

要查看详细的文本标签,需要使用UITableViewCellStyleSubtitle样式创建单元格

例如:

 - (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell * cell = nil;


进入您的nib并连接UITable Outlet并给propar委派:)您可以将UItableView数据源方法粘贴到此处吗?@NitinGohel,我编辑了我的代码。您可以为-cellForRowAtIndexPath:?@user1673099添加代码吗?您曾经能够显示cell.detailLabel.text吗?如果是的话,你能分享一下细节吗?我的问题是:现在,我的代码如上所述。但当我选择该行时,弹出框不会被忽略。你能帮我吗?[你的Popover解雇Popoveranimated:是];在didSelectRowAtIndexPath方法中写入此内容。但是我的popover在不同的类中&我的tableview在不同的类中,我打开了我的popover。请检查我的更新答案,您只需创建
NSNotificationCenter
希望它能帮助您,并且您可以理解方法或代码抱歉,没有发生任何事情
return cell;
}