我有一個視圖,其中有一個標籤欄和一個表格視圖。在某個時候,我稱之爲模態視圖,當我忽略它時,原始視圖似乎伸展或向下移動,因爲背景圖像較低,並且表視圖較長,直到最後一個單元超出幀的位置。解散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]框架會變得混亂(意味着它超出了你的內容視圖的底部)? –