iOS Popover和tableviewcontroller刷新问题

时间:2012-12-05 10:11:57

标签: ios xcode ipad uitableview uipopovercontroller

我正在编写一个模拟iPad主/细节布局的项目。 所以我有一个masterView(UITableView),一个detailView(UICollectionView),一个全局导航栏和一个TabBar。 标签栏中填充了一些我需要选择的类别,并根据所选的tabbaritem填写了主视图。

在横向模式下,当显示主视图和详细视图时,一切正常。 在纵向模式下,我的主视图被隐藏,我有一个按钮,打开一个popupcontroller与我的主人在其中。问题是这个弹出窗口似乎没有显示对masterview内容进行的更改

MasterView是一个UITableViewController。 我已经正确实现了委托和数据源方法。

以下是打开/关闭popover

的代码
if(myPopIsVisible)
{
    myPop = [[UIPopoverController alloc]initWithContentViewController:myMasterView];
    [myPop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    myPopIsVisible = YES;
}
else
{
    [myPop dismissPopoverAnimated:YES];
    myPopIsVisible = NO;
}

检入调试它会让我看到myMasterView的正确内容(行的数量和内容),但它只显示应用程序加载的第一个内容。

我正在使用ARC ......

这是myMasterView类实现

@implementation myMasterView{
    NSArray *cellTitles;
    NSArray *cellIco;
    NSArray *cellTag;
}

- (void) setData:(NSArray *)titles :(NSArray *)icos :(NSArray *)tags
{
     cellTitles = titles;
     cellIco = icos;
     cellTag = tags;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

    if(cell == nil){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
    // Configure the cell...
        cell.textLabel.text = [cellTitles objectAtIndex:indexPath.row];
        cell.tag = [[cellTag objectAtIndex:indexPath.row] integerValue];
    #warning icona non impostata
    //    cell.imageView.image = [cellIco objectAtIndex:indexPath.row];
    }
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [cellTitles count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(isPopover)
    {
        isPopover = NO;
        [master dismissPopoverController];
    }

}

0 个答案:

没有答案