1掐场、做iOS 10的本地推送
- (nullable NSURL *)URLForResource:(nullable NSString *)name withExtension:(nullable NSString *)ext API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));返回空值
2拦止、單例
+ (instancetype)shared {
return [[self alloc] init];
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
static id instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [super allocWithZone:zone];
});
return instance;
}
3、通知刷新 可以 修改為本地數(shù)據和網絡數(shù)據同時修改(eg:刪除操作post成功時狸眼,修改本地數(shù)據,減少一次網絡請求 -> 通知刷新)
4勒极、accessKey 內部校驗敞恋,進行安全驗證
5、網絡狀態(tài)碼 http://www.lampweb.org/seo/5/10.html
6、push UIImagePickerViewController灶泵? 不能push導航控制器 只能模態(tài)出來
7育八、關于網絡獲取alert問題,解決方式
1)WiFi 下赦邻,臨時啟動蜂窩網絡的無線網絡助理髓棋,就能彈出那個允許使用數(shù)據了
2)如果在權限列表里 修改別的APP的權限 這個APP可能會重新刷新 出在列表里
8、AVPlayer 循環(huán)播放 加通知 // 跳到最新的時間點開始播放 [_player seekToTime:CMTimeMake(0, 1)]; [_player play]
9惶洲、Xcode8.0 打印問題 OS_ACTIVITY_MODE -> Disable
10按声、正式包 只有描述文件,沒有證書恬吕,報錯誤xxx doesn't include signing certificate "iPhone Distribution鏈接手機也可以調試签则,因為這個開發(fā)狀態(tài)
11、swift中弱化self [weak self] in guard let strongSelf = self else { return }
12铐料、tableview去除多余空白cell tableView.tableFooterView = UIView()
13渐裂、滑動scrollView時 隱藏鍵盤 scrollView.keyboardDismissMode = .OnDrag
14、開關提示音 監(jiān)聽開關的改變狀態(tài)余赢,默認開啟芯义,APP殺死哈垢,后臺妻柒,均為后臺push一個音效,如果再APP中關閉提示音耘分,可以讓后臺中的sound字段不傳遞举塔,則無音效
15、在AppDelegate中present控制器時求泰,需要拿到主控制器去present
16央渣、nav 44,狀態(tài)欄 20渴频,tabbar 49 automaticallyAdjustsScrollViewInsets = false 恢復自定義芽丹,關閉系統(tǒng)自適應
17、UISearchBar 非謂詞:從總數(shù)組使用forin遍歷每一個item卜朗,使用item小寫使用hasPrefix比對 searchText的小寫
18拔第、富文本 鍵值對錯誤 libc++abi.dylib: terminating with uncaught exception of type NSException
19、func didUpdateRecentSession(recentSession: NIMRecentSession, totalUnreadCount: Int) {} app退到后臺可在此方法中進行對icon的badge的修改
20场钉、3DTouch 中的分享功能蚊俺,是由系統(tǒng)自動實現(xiàn)的,正常都需要進入app進行邏輯處理逛万,也就是說泳猬,正常添加item最多四個,加上分享item,最多五個
21得封、tableView的數(shù)據源文件可以使用可變數(shù)組插入新數(shù)據芦疏,并且再最后reloadData
22宴倍、枚舉能定義字符串么?
答:OC中不能定義字符串,只能定義NSInterger和NSUInterger
23返敬、數(shù)組指定類型為什么寫枚舉不可以?
答:OC中數(shù)組可以指定類型谴分,即“泛型”鸠天,方式 NSArray <NSString *> * arr = @[];
在OC中,指定的類型只能為 對象類型 和 block
24手形、基類.m方法中實現(xiàn)一個私有方法啥供,子類.m方法中同名實現(xiàn)了一個私有方法,會走子類
25库糠、swift代理伙狐,協(xié)議中代理如果定義為可選類型,則需要delegate瞬欧?.doAction?() 這樣調用贷屎,防止崩潰
26、 'weak' mayonly be applied to class and class-bound protocol types
27艘虎、
@objc protocol BookTiltleViewDelegate{ optional
func choiceFace()
}
protocol BookTiltleViewDelegate:class//NSObjectProtocol{
func choiceFace()
}
28唉侄、tableview動畫 guideCenterView.tableView.beginUpdates()//增刪改查操作
guideCenterView.tableView.endUpdates()
29、enumerateObjectsUsingBlock枚舉遍歷
30野建、在imageView上添加手勢需要將isUserInteractionEnabled = YES
31属划、國際化,指在本地配置文件CFBundleDisplayName(Icon),NSLocalizedString(@"buttonTitle", nil)配合使用
32候生、messary 更新約束時只需要再block中更新不同的約束就可以同眯,相同的不需要再寫一遍
33、
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[application setApplicationIconBadgeNumber:0];JPUSH點擊一條push清空其他push
[application cancelAllLocalNotifications];
[JPUSHService setBadge:0];開始受到兩條推送,然后點開,角標消失,系統(tǒng)再發(fā)送推送,角標變?yōu)?
}
34唯鸭、
- NSString *str1 = @"can you \n speak English";
- let str = NSCharacterSet(charactersInString: "qwertyuiopasdfghjklzxcvbnm")
- //在str1這個字符串中搜索\n须蜗,判斷有沒有
- if ([str1 rangeOfString:str].location != NSNotFound) {
- NSLog(@"這個字符串中有\(zhòng)n");
- }
- //rangeOfString 前面的參數(shù)是要被搜索的字符串,后面的是要搜索的字符
- //NSNotFound 表示請求操作的某個內容或者item沒有發(fā)現(xiàn)目溉,或者不存在
35明肮、縮略圖可以通過設置imageView的contentmode為A-Fill再將其切掉多余的即可
36、日歷展示統(tǒng)一為公歷 formatter/datePicker.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)
37停做、GCB直連 時時刷新 長連接
38晤愧、
//MARK: 撥打電話
class func callPhoneNumber(number: String) {
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "telprompt://\(number)")!) {
UIApplication.sharedApplication().openURL(NSURL(string: "telprompt://\(number)")!)
} else {
let alert = UIAlertView(title: "該設備不能撥打電話\n\(number)", message: nil, delegate: nil, cancelButtonTitle: "知道了")
alert.show()
}
}
39、if let語法
//如果NIMSDK.sharedSDK().conversationManager.allRecentSessions() 有值時 將對應值賦值給array蛉腌;如果沒有值時不進入代碼塊
if let array = NIMSDK.sharedSDK().conversationManager.allRecentSessions() {
strongSelf.nimSessions = array
Print.dlog("\(strongSelf.nimSessions.count) \(strongSelf.nimSessions.underestimateCount())")
}
40官份、
當ContentSize屬性小于等于Frame時,將不會出發(fā)滾動
so -> ContentSize要大于 Frame
41只厘、關于tableviewcell動畫和tableview的左滑多選項https://github.com/pengshengsongcode/CustomTableViewAnimation
42、swift 中弱化 self
carView.changeCarClickBlock = {[weak self] in
guard let strongSelf = self else { return }
let myCarVC = HBCMyCarViewController()
myCarVC.hidesBottomBarWhenPushed = true
strongSelf.belongVC?.navigationController?.pushViewController(myCarVC, animated: true)
}
43舅巷、膠囊按鈕
//設置圓角
UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.btn.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(100, 100)];
CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
maskLayer1.frame = self.btn.bounds;
maskLayer1.path = maskPath1.CGPath;
self.btn.layer.mask = maskLayer1;
重構8嵛丁!钠右!
1赋元、語言方法異同
swift cellModel! is HBCTripFundInviteCellModel
oc[cellModel isKindOfClass:[HBCTripFundInviteCellModel class]]
2、泛型nsarray<nsstring *> *arrs
3飒房、@property (nonatomic, strong) NSMutableArray *dataList;??
@property (nonatomic,copy) NSMutableArray *dataList; 初始化搁凸,add?
4、OC枚舉不能放非NSInteger,NSUInteger,OC指定類型不能指定枚舉狠毯,只能指定對象和Block
5护糖、[[UIPasteboard generalPasteboard] setValue:aValue forPasteboardType:UIPasteboardTypeListString[0]];
6、switch case OC應用
switch (type) {
case 1: case 2:
{
}
break;
case 3:
{
HBCDailyJourneyViewController *vc = [[HBCDailyJourneyViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case 4:
{
HBCSingleJourneyViewController *vc = [[HBCSingleJourneyViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
default:
break;
}
7嚼松、跳轉 APPStroe
//999773808
let commentURL = "itms-apps://itunes.[apple.com/app/id\](http://apple.com/app/id%5C)(appID)"
let URL = NSURL(string: commentURL)
if URL == nil {
return
}
if UIApplication.sharedApplication().canOpenURL(URL!) {
UIApplication.sharedApplication().openURL(URL!)
}
8嫡良、動態(tài)加元素
NSMutableArray *section1 = @[].mutableCopy;
[self.hbc_sections removeAllObjects];
[self.hbc_sections addObject:section1];
9、當viewdidload結束 高版本會自動reloaddata tableview
10献酗、ios7.0 layoutSubviews 中邏輯代碼需要再[super layoutSubviews];之前寝受,否則崩潰
11、 NSData *imageData = UIImageJPEGRepresentation(img, 0.75);
UIImage *image = [UIImage imageWithData:imageData];
NSData *compressData = UIImageJPEGRepresentation(img, 0.4);
UIImage *compressedImage = [UIImage imageWithData:compressData];