我有一个UITableViewController
,其中包含标题中的一个按钮,允许用户发布图片。按下按钮时,我以编程方式创建一个postButton,cancelButton和captionTextView -
UIButton *postButton = [[UIButton alloc]initWithFrame:CGRectMake(160, 0, 160, 50)];
postButton.tag = 8934;
postButton.backgroundColor = [UIColor blueColor];
[postButton setTitle:@" Post" forState:UIControlStateNormal];
[postButton setImage:[UIImage imageNamed:@"addPicture.png"] forState:UIControlStateNormal];
[postButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[postButton addTarget:self action:@selector(addImage) forControlEvents:UIControlEventTouchUpInside];
UIButton *cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 160, 50)];
cancelButton.tag = 8934;
cancelButton.backgroundColor = [UIColor redColor];
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[cancelButton addTarget:self action:@selector(cancelImage) forControlEvents:UIControlEventTouchUpInside];
然后 - self.view addSubview:
。用户按下帖子或取消按钮后 -
for (UIView *subview in [self.view subviews]) {
if (subview.tag == 8934 || subview.tag == 2387)
[subview removeFromSuperview];
}
}
删除按钮和textViews,但删除它们后,tableView
向上移动,第一个单元格的一部分隐藏在naviagtionBar
答案 0 :(得分:0)
我是傻瓜。在删除子视图而不是之前
之后调用navigationBar.hidden = false