我正在運行一個奇怪的問題,它出現在哪裏。我不確定是否因爲我沒有更新到Xcode 4.2.1或者它是否是iOS 5.我有一個在OS 4.0 - 5.0上運行的iPad應用程序。UITableView未顯示運行iOS 5的iPad
我有一個UITableView包含在一個視圖模態地顯示爲表單。
該表在4.x上顯示正常運行,但在5.0上運行時該表消失。
我知道每個人都聽過這一百萬次,但是昨天文學作品很好,我沒有改變任何東西,現在它不起作用。我有一個來自昨天的工作副本,安裝在運行iOS 5的額外iPad上。今天它不想工作。
以下是我如何設置,也許你可以發現一個問題。
UITableView在IB中創建。數據源和委託被設置。
的觀點被稱爲像這樣:
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 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的
是否有任何新的編譯器警告或運行時警告? – dtuckernet
負面的先生。我甚至在' - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath'中設置了斷點以確保它正在被調用。 (它被稱爲)。 – random
如果你自己解決了你的問題,它習慣上使用堆棧溢出來將你的解決方案作爲答案並自己接受;這樣每個人都可以看到問題已經解決:) – deanWombourne