【发布时间】:2012-01-19 18:52:18
【问题描述】:
我遇到了一个奇怪的问题,该问题从现在出现在哪里。我不确定是因为我没有更新到 Xcode 4.2.1 还是 iOS 5。
我有一个在操作系统 4.0 - 5.0 上运行的 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 我们得到这个:
Price 视图的 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];
}
非常感谢您的帮助,并一如既往地感谢您抽出宝贵的时间。
回答
我设法找出了问题所在,但我不确定它为什么会发生。也许有人可以对此有所了解。
我必须插入
[table reloadData];
-(void)viewDidLoad结尾
我不确定为什么它必须存在于 iOS 5 而不是 iOS 4.x
【问题讨论】:
-
是否有新的编译器警告或运行时警告?
-
否定先生。我什至在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath中设置了断点以确保它被调用。 (它正在被调用)。 -
如果您自己解决了问题,通常在堆栈溢出时将您的解决方案作为答案并自己接受;这样每个人都可以看到问题已经解决了:)
标签: objective-c xcode ipad uitableview ios5