很多来自stackoverflow
adding subview to UIImageView
拖一个UIView
把它的类型改为UIImageView
这时候就能在这个View
在添加子视图了。tree
命令一样显示view
的层次结构。[self.view recursiveDescription]
tableView
滚动的时候始终以row
的高度为单位。 首先想到的是tableView
继承自scrollView
也有pagingEnabled
属性。 设置这个属性之后会发现,滚动的时候是以tableView
的height
为单位滚的。 实现以下这个代理方法就可以解决了,滚动结束的时候始终停留在某个row
上面并且还能够获得indexPath
.-(void)scrollViewWillEndDragging:(UIScrollView*)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint*)targetContentOffset {
// Get index path for target row
NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:(*targetContentOffset)];
// Set new target
(*targetContentOffset) = [self.tableView rectForRowAtIndexPath:indexPath].origin;
}
self.tableView.tableFooterView = [UIView alloc] init]
- (void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[_searchBar endEditing:YES];
}
其实还有一个神器IQKeyboardManager
//黑色改白色 不要忘记设置plist
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//导航条颜色
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
//title的颜色和字体
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}];
//透明or不透明。这个会影响storyBoard纵坐标的位置。注意这个方法与`SetbackgroundImageForBarMetrics`一起使用时导航的变化。
[[UINavigationBar appearance] setTranslucent:NO];
//serarchBar的颜色,比如说取消按钮。再也不会遍历子视图了。
[[UISearchBar appearance] setTintColor:[UIColor whiteColor]];
每个控件的appearance
都可以去看下。有时候能省很多事。不用一个个的单独设置。
tableView reload
写在了结束刷上下拉刷新方法之前,竟然不崩溃。 >tableView数据源变化之后尽可能早的刷新tableView,这样数组越界的可能性就会降低很多。Xcode
archive之后上传报错 ERROR ITMS-90207: "Invalid Bundle. The bundle at 'example.app' does not contain a bundle executable
用
vi
打开Info.plist
检查有没有特殊字符。有时候从别的地方复制过来的会有特殊字符,删掉重新添加再打包就可以上传了。
iOS7
+的UILabel会自动将text行尾的空白符全部去除。半角空格\0x20
和制表符\t
除外。在text后面追加这两个符号即可。Xcode
调试的状态显示indexing....
,卡很久Open your Project Folder.
Find ProjectName.xcodeproj file.
Right-Click Copy and Paste to Safe Place.
Right-Click Show Package Contents.
Find project.xcworkspace file and delete that file.
Reopen Your Project and clean and Rebuild.
let notification = UILocalNotification()
notification.soundName = "sound.bundle/" + xxx.wav
Swift
print
在Xcode
->Devices
-> 'xxx的iPhone8' 不会打印日志, NSLog
会打印。