原始问题如下。 我解决了我的问题。我为tableview和mapview设置了相同的视图控制器。我在viewDidLoad中拥有了所有的mapView init。这些都一起对我来说有以下问题:MKMapView不断重置回世界视图
1)当标签栏控制器模态地呈现,我收到一个内存警告调用viewDidUnload(我什么都没有在之前)。当模式标签栏控制器被解雇并且viewDidLoad被调用时,它重置我的mapView。 2)当标签栏控制器以模态方式呈现,并且在移动到带有视图控制器的选项卡并切换到该选项卡之前收到内存警告时,我的viewDidLoad在我的mapView控制器中调用,它重置了我的地图,重置表格属性,以便我的tableView不起作用。
非常感谢Anomie帮助我调试此问题,并更好地了解这些碎片是如何连接的。事情现在很好,我的应用程序有更好的设计。
原题: 我有了一个MapView,当我提出一个标签栏视图控制器模态,每过一段时间,当我取消模态视图控制器的地图重置回世界观就像一个复位的应用按钮被按下。有几个细节:
- 这在模拟器上从未发生过
- 我注意到身边发生这种情况我的设备上的时间内存警告
- 我没有做任何事情,当内存不足警告我的应用程序发生,所以没有什么应该已经触及地图视图
另外,我的模态视图控制器中的tableview有时也显示为空(以及内存警告的时间)。当它出现空白时,通常不会调用通常用于获取行数,节数和数据的方法。在取消模态视图控制器,并重新打开它时,数据是有细,所以数据是没有得到清除..
代码我用来创建标签栏控制器,选择器和表:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// Display only a person's address(es)
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonAddressProperty],
nil];
picker.displayedProperties = displayedItems;
UITabBarItem *peoplePickerTabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:0];
picker.tabBarItem = peoplePickerTabBarItem;
UITableViewController *tvc = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
tvc.tableView.delegate = self;
tvc.tableView.dataSource = self;
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:tvc];
UIBarButtonItem *uibbiCancel = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(cancelTable)];
tvc.navigationItem.rightBarButtonItem = uibbiCancel;
tvc.title = @"Recents";
UITabBarItem *nvcTabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:2];
nvc.tabBarItem = nvcTabBarItem;
tbc = [[UITabBarController alloc] init];
NSArray *sections = [[NSArray alloc] initWithObjects:picker, nvc, nil];
[tbc setViewControllers:sections];
[self presentModalViewController:tbc animated:YES];
[nvcTabBarItem release];
[uibbiCancel release];
[tvc release];
[peoplePickerTabBarItem release];
[picker release];
[nvc release];
[sections release];
[tbc release];
您可以在模拟器中发出内存警告(在硬件菜单中)。在设备上,您可以在调试器中执行相同的操作:'call(void)[[UIApplication sharedApplication] _performMemoryWarning]'。也许,这有助于调试问题。 – 2011-03-08 21:40:59