【发布时间】:2011-04-12 15:18:14
【问题描述】:
我是 Objective-C/Cocoa Touch 的新手,希望有人可以帮助解决以下问题。
我在屏幕底部有一个带有地图视图控件和 UIToolBar 的视图。当用户单击地图上的图钉时,他们可以深入查看包含位置详细信息的分组 UITableView。
这是通过推送一个新的导航控制器来完成的:
MapAnnotation *tappedLocation = (MapAnnotation *)[view annotation];
LocationDetailsViewController *placeDetails = [[LocationDetailsViewController alloc] initWithNibName:@"LocationDetailsViewController" bundle:nil];
[self.navigationController pushViewController:placeDetails animated:YES];
[placeDetails release];
在分组的 UITableView 中,屏幕底部还有一个 UIToolbar,但它是通过编程方式设置的(代码如下)。
问题是当用户离开分组的 UITableView 并带着地图返回主视图时,他们仍然看到 UITableView 中的 UIToolbar,而不是在 IB 中设置的原始 UIToolbar。
有人知道我如何从分组的 UITableView 中“取消” UIToolbar 吗?
UIToolbar *toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleDefault;
[toolbar sizeToFit];
toolbar.frame = CGRectMake(0, 436, 320, 44);
toolbar.tag = 123;
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *emailButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:self
action:@selector(email:)];
//Add buttons to the array
NSArray *items = [NSArray arrayWithObjects: flexItem, flexItem, flexItem, emailButton, nil];
[emailButton release];
[flexItem release];
//add array of buttons to toolbar
[toolbar setItems:items animated:YES];
[self.navigationController.view addSubview:toolbar];
【问题讨论】:
标签: iphone cocoa-touch uitableview uitoolbar