我有一个视图,其中有一个标签栏和一个表格视图。在某个时候,我称之为模态视图,当我忽略它时,原始视图似乎伸展或向下移动,因为背景图像较低,并且表视图较长,直到最后一个单元超出帧的位置。解散modalview后UITableView和背景图像向下移动
我所说的模态视图从tableView:didSelectRowAtIndexPath
:
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableDictionary *row = [[[[self.productDetails valueForKey:@"sections"] objectAtIndex:indexPath.section] valueForKey:@"rows"] objectAtIndex:indexPath.row];
NSMutableDictionary *post = [self.productDetails valueForKey:@"post"];
if ([[row valueForKey:@"type"] isEqualToString:@"pick"])
{
self.xPicker = nil;
self.xPicker.options = nil;
self.pickerOptions = nil;
self.xPicker = [[[TablePicker alloc] initWithNibName:@"TablePicker" bundle:[NSBundle mainBundle]] autorelease];
NSMutableDictionary *newPicker = [[[NSMutableDictionary alloc] init] autorelease];
[newPicker setValue:[NSString stringWithFormat:@"%d", indexPath.section] forKey:@"section"];
[newPicker setValue:[NSString stringWithFormat:@"%d", indexPath.row] forKey:@"row"];
[newPicker setValue:[row valueForKey:@"options"] forKey:@"options"];
[newPicker setValue:[row valueForKey:@"value"] forKey:@"value"];
self.xPicker.options = [NSMutableDictionary dictionaryWithDictionary:newPicker];
self.pickerOptions = [NSDictionary dictionaryWithDictionary:newPicker];
self.xPicker.view.frame = self.view.bounds;
[self presentModalViewController:self.xPicker animated:YES];
}
}
里面的模态视图控制器,我做一些东西,然后触发一个通知,让家长控制器知道它的确定将其关闭。这部分感觉不对,但我偶尔得到一个错误,当我有模式的看法呼叫:
[self.parentViewController dismissModalViewControllerAnimated:YES];
不管怎么说,代码块,我解雇模态视图如下:
- (void) reloadCell
{
[self dismissModalViewControllerAnimated:YES];
if (self.xPicker.choice != nil)
{
NSDictionary *choice = self.xPicker.choice;
NSMutableDictionary *row = [[[[self.productDetails valueForKey:@"sections"] objectAtIndex:[[choice valueForKey:@"section"] intValue]] valueForKey:@"rows"] objectAtIndex:[[choice valueForKey:@"row"] intValue]];
[row setObject:[choice valueForKey:@"value"] forKey:@"value"];
[[self.productDetails valueForKey:@"post"] setObject:[choice valueForKey:@"value"] forKey:[row valueForKey:@"key"]];
Request *xReq = [[[Request alloc] init] autorelease];
[NSThread detachNewThreadSelector:@selector(updateOrderFromProductDetails:) toTarget:xReq withObject:[self.productDetails valueForKey:@"post"]];
self.xPicker = nil;
}
}
我不知道它是否相关,但是我发现有趣的是,当我在设备处于横向模式时展示这个模式控制器时,视图变得不可思议。
有谁知道如何解决这个问题?
编辑:经过一番搜索,看来,这两个问题是相关的,有我的当前视图控制器是另一个视图控制器的子视图做,但不是通过导航控制器。
据我了解,我决定不使用导航控制器会让我的视图堆栈产生混淆。我有一种感觉会回来咬我的屁股。
不幸的是,我似乎无法找到解决我的问题的任何地方。
表视图的框架必定有问题。你能发布你的整个实现(.m)文件吗? –
你有任何导航控制器或工具栏? –
因此,当你调用[myTableView reloadData]框架会变得混乱(意味着它超出了你的内容视图的底部)? –