UITableView未显示运行iOS 5的iPad

问题描述:

我正在运行一个奇怪的问题,它出现在哪里。我不确定是否因为我没有更新到Xcode 4.2.1或者它是否是iOS 5.我有一个在OS 4.0 - 5.0上运行的iPad应用程序。UITableView未显示运行iOS 5的iPad

我有一个UITableView包含在一个视图模态地显示为表单。

该表在4.x上显示正常运行,但在5.0上运行时该表消失。

我知道每个人都听过这一百万次,但是昨天文学作品很好,我没有改变任何东西,现在它不起作用。我有一个来自昨天的工作副本,安装在运行iOS 5的额外iPad上。今天它不想工作。

以下是我如何设置,也许你可以发现一个问题。

  1. UITableView在IB中创建。数据源和委托被设置。

  2. 的观点被称为像这样:

GuidedSearchPriceViewController *guide = [[GuidedSearchPriceViewController alloc] initWithNibName:@"GuidedSearchPriceViewController_iPad" bundle:nil]; 
UINavigationController *temp = [[UINavigationController alloc] initWithRootViewController:guide]; 
temp.modalPresentationStyle = UIModalPresentationFormSheet; 
[guide setModalDelegate:self]; 
[guide setAppDelegate:self.appDelegate]; 
temp.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:temp animated:YES]; 

的iOS 4.x中我们得到这样的: iOS 4.x

不过是的iOS 5我们得到这个: iOS 5

价格视图的viewDidLoad方法是:

- (void)viewDidLoad 
{ 

    [super viewDidLoad]; 

    //Tried for testing but still does nothing 
    self.table.delegate = self; 
    self.table.dataSource = self; 

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Type" style:UIBarButtonItemStyleBordered target:self action:@selector(nextScreen)]; 
    addButton.enabled = NO; 
    self.navigationItem.rightBarButtonItem = addButton; 

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
     UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismiss)]; 

     self.navigationItem.leftBarButtonItem = cancel; 
     self.navigationController.navigationBar.tintColor = [UIColor redColor]; 
     self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", [[NSBundle mainBundle] bundlePath], RP_iPad_FormsheetBackground]]]; 

    } else 
     self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", [[NSBundle mainBundle] bundlePath], RP_BackgroundImage]]]; 

    // Make sure the background of the table is clear. I have also tried taking this out 
    // to resolve the disappearing issue but it has no effect. 
    if ([self.table respondsToSelector:@selector(backgroundView)]) { 
     [self.table setBackgroundView:nil]; 
     [self.table setBackgroundView:[[UIView alloc] init]]; 
     [self.table setBackgroundColor:UIColor.clearColor]; 
    } 

    priceList = [[NSArray alloc] initWithObjects:@"$750", @"$1000", @"$1250", @"$1500", @"$1750", @"$2000", @"$2000 +", nil]; 

} 

非常感谢您的任何帮助,并一如既往地感谢您的时间。


ANSWER

我设法弄清楚问题是什么,但我不知道为什么它正在发生。也许有人可以对此有所了解。

我不得不插入

[table reloadData];

-(void)viewDidLoad

末我不知道为什么它必须是有在iOS 5中,但不是在iOS的4.x的

+0

是否有任何新的编译器警告或运行时警告? – dtuckernet

+0

负面的先生。我甚至在' - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath'中设置了断点以确保它正在被调用。 (它被称为)。 – random

+0

如果你自己解决了你的问题,它习惯上使用堆栈溢出来将你的解决方案作为答案并自己接受;这样每个人都可以看到问题已经解决:) – deanWombourne

如果您使用的是UITableViewController与您的表格视图,“When the table view is about to appear the first time it’s loaded, the table-view controller reloads the table view’s data.”

“If you choose not to use UITableViewController for table-view management, you must replicate what this class gives you ‘for free.’”

第二个链接中的示例代码在设置其代表和数据源后,将reloadData发送到表中。也许在iOS 4中,表格视图会在加载时自动重新加载,而在iOS 5中,它会更改为匹配文档。