关键的两句:
1
2
|
tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension
|
场合1:
只有一个UILabel
场合2:
有多个UILabel,相互之间有约束
场合3:
只有一个UILabel,但是未设置Bottom的底部约束,导致UITableViewCell不能自适应高度.(默认高度为44)
场合4:
因为没有UILabel,所以UITableViewCell不能自适应高度.(默认高度为44)
环境: XCode7,Swift2.0
系统: iOS 8.0以上
iPhone6s以上机型的3D Touch简单demo
购物车(作者:smile82475)
用 CAAnimation 的基础动画组合而成的加入购物车动画效果。点击购物车按钮,图片会从按钮沿着一定路径落入购物车,移动动画完成后购物车会闪动动画
测试环境:Xcode 6.2,iOS 6.0 以上
coredata的增删改查 -MyCoreData(作者:libing1125)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
- (IBAction)add:(id)sender {
Player *playerObject = [NSEntityDescription insertNewObjectForEntityForName:@
"Player"
inManagedObjectContext:self.cdViewController.managedObjectContext];
playerObject.name = self.nameTF.text;
playerObject.age = [NSNumber numberWithInteger:[self.ageTF.text integerValue]];
playerObject.team = self.team;
[self.cdViewController saveContext];
[self dismissViewControllerAnimated:YES completion:nil];
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// NSManagedObjectContext *tempContext = [[NSManagedObjectContext alloc]init];
// [tempContext setPersistentStoreCoordinator:sharedPersistenStoreCoordinator];
//
// Player *playerObject = [NSEntityDescription insertNewObjectForEntityForName:@"Player" inManagedObjectContext:tempContext];
// playerObject.name = self.nameTF.text;
// playerObject.age = [NSNumber numberWithInteger:[self.ageTF.text integerValue]];
// //playerObject.team = self.team;
// playerObject.team = (Team *)[tempContext objectWithID:self.teamID];
// NSError *error = nil;
// if (tempContext && [tempContext hasChanges] && ![tempContext save:&error]) {
// NSLog(@"Error %@, %@",error,[error localizedDescription]);
// abort();
// }
//
// dispatch_async(dispatch_get_main_queue(), ^{
// [self dismissViewControllerAnimated:YES completion:nil];
// });
//
// });
}
- (void)mocDidSaveNotification:(NSNotification *)notification
{
NSManagedObjectContext *saveContext = [notification object];
if
(saveContext == self.managedObjectContext ) {
return
;
}
if
(saveContext.persistentStoreCoordinator != self.persistentStoreCoordinator) {
return
;
}
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@
"Merge changes from other contex.\n"
);
[self.managedObjectContext mergeChangesFromContextDidSaveNotification:notification];
});
}
|
测试环境:Xcode 6.2,iOS 6.0 以上
一种网络层与业务层的设计方案(作者:长剑废水)
iOS中一种网络层与业务层的设计方案
测试环境:Xcode 6.2,iOS 6.0 以上