上图代码:
// 删除列表最后一行
- (IBAction)remove:(UIBarButtonItem *)sender {
// 获取列表的最后一行view
UIView *lastRowView = [self.view.subviews lastObject];
[UIView animateWithDuration:0.5 animations:^{
CGRect tempF = lastRowView.frame;
tempF.origin.x = 320;
lastRowView.frame = tempF;
lastRowView.alpha = 0;
} completion:^(BOOL finished) {
// NSLog(@"最后一行View删除完毕");
// 删除列表的最后一行view
[lastRowView removeFromSuperview];
// 如果父控件的子控件只剩一个,设置删除项为不可用
NSUInteger subviewCount = self.view.subviews.count;
_deleteItem.enabled = subviewCount > 1;
NSLog(@"nei--%d",self.view.subviews.count);
}];
NSLog(@"wai--%d",self.view.subviews.count);
}
删除红色UIView后,NSLog打印的结果为什么不同? |