我想我隐藏了工具栏。我是否需要进行任何其他取消分配?
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationItem.title = @"Add Recipients";
self.navigationController.toolbarHidden=NO;
UIBarButtonItem *localItem;
UIBarButtonItem *remoteItem;
localItem = [[ UIBarButtonItem alloc ] initWithTitle: @"Local"
style: UIBarButtonItemStyleBordered
target: self
action: @selector( localRecipients: ) ];
remoteItem = [[ UIBarButtonItem alloc ] initWithTitle: @"Remote"
style: UIBarButtonItemStyleBordered
target: self
action: @selector( remoteRecipients: ) ];
self.toolbarItems = [ NSArray arrayWithObjects: localItem,remoteItem,nil ];
[localItem release];
[remoteItem release];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.toolbarHidden=YES;
}
答案 0 :(得分:2)
您负责释放您创建的对象。由于您没有创建工具栏,因此您不负责发布它。
答案 1 :(得分:2)
您不需要进行取消分配,因为您已经通过释放UIBarButtonItem
来解决代码问题。
如果您保留toolbarItems
,请尝试使用以下代码。
self.toolbarItems = nil ;
self.toolbarItems = [ NSArray arrayWithObjects: localItem,remoteItem,nil ];