在我的集合视图中,我在集合单元格中添加了带阴影的自定义视图.
我使用以下代码将阴影添加到视图中.
cell.shadowView.backgroundColor = [UIColor greenColor];
cell.shadowView.layer.masksToBounds = NO;
cell.shadowView.layer.shadowColor = [UIColor redColor].CGColor;
cell.shadowView.layer.shadowOffset = CGSizeMake(-2.0f, 2.0f);
cell.shadowView.layer.shadowOpacity = 1.0f;
cell.shadowView.layer.shadowRadius = 4.0f;
cell.shadowView.layer.shouldRasterize = YES;
cell.shadowView.layer.rasterizationScale = [UIScreen mainScreen].scale;
Run Code Online (Sandbox Code Playgroud)
每当我重新加载单元格时,重新加载的单元格每次都会闪烁.以下代码用于重新加载单元格.
[self.collectionView performBatchUpdates:^{
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
NSArray* indexPathArray = [NSArray arrayWithObjects:indexPath, nil];
[self.collectionView reloadItemsAtIndexPaths:indexPathArray];
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
我想在重新加载单元格时避免这种闪烁.
我可以通过在[UIView performWithoutAnimation:^ {}]动画块中运行performBatchUpdates来避免闪烁.但它会导致现有动画代码破损.
有没有办法避免这个闪烁的问题?
谢谢.
我正在尝试使用日期"1 oct 2013 8:00:00"创建NSDate对象.我使用了以下代码
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:2013];
[components setMonth:10];
[components setDay:1];
[components setHour: 8];
[components setMinute: 00];
[components setSecond: 00];
NSDate *date = [calendar dateFromComponents:components];
Run Code Online (Sandbox Code Playgroud)
但是,当我打印日期时,它会给出错误的时间"2013-10-01 02:30:00 +0000"
我有一个表格视图,显示数组中的联系人.我通过以下方式设置表视图委托.
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [contactArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"ContactCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [contactArray objectAtIndex:indexPath.row];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60.0;
}
Run Code Online (Sandbox Code Playgroud)
但表视图中的第一个单元格始终为空.它仅从第二个单元格开始显示.我认为这可能是标题视图.所以我使用以下委托方法删除了标头.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.0;
}
Run Code Online (Sandbox Code Playgroud)
但还是有问题.我附上了关于这个问题的截图.
任何帮助将不胜感激.