1、使用UIWebView加載網(wǎng)頁時(shí)瓤介,當(dāng)頁面中有視頻播放時(shí)吕喘,調(diào)用系統(tǒng)的播放器進(jìn)行播放,但是點(diǎn)擊全屏播放然后返回時(shí)刑桑,發(fā)現(xiàn)狀態(tài)欄少了一部分兽泄,這里需要對(duì)退出全屏進(jìn)行監(jiān)聽,具體代碼如下:
//監(jiān)聽UIWindow隱藏
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(endFullScreen) name:UIWindowDidBecomeHiddenNotification object:nil];
-(void)endFullScreen{
if ([UIApplication sharedApplication].statusBarHidden) {
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:false];
}
}
別忘記在后面取消通知
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIWindowDidBecomeHiddenNotification object:nil];
}
2漾月、更新Xcode10.3后運(yùn)行沒有可選擇的模擬器,在真機(jī)上運(yùn)行報(bào)錯(cuò)胃珍,解決辦法:
Kill all simulator processes
$ sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
Set the correct Xcode path
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
If that doesn’t work, reset all simulators
$ xcrun simctl erase all
3梁肿、在iPhone X以上的設(shè)備使用MJRefresh時(shí)上拉的狀態(tài)一直存在,可以在AppDelegate通過添加
if (@available(iOS 11.0, *)) {
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIApplicationBackgroundFetchIntervalNever];
[[UITableView appearance] setEstimatedRowHeight:0.f];
[[UITableView appearance] setEstimatedSectionHeaderHeight:0.f];
[[UITableView appearance] setEstimatedSectionFooterHeight:0.f];
}
4觅彰、iOS撥打電話 由于最近APP審核提示會(huì)停止使用UIWebview API吩蔑,所以修改了以前使用UIWebview打電話的方式
/**
* 撥打電話,彈出提示填抬,撥打完電話回到原來的應(yīng)用
* 注意這里是 telprompt://
*/
NSString *phoneStr = [NSString stringWithFormat:@"telprompt://%@",self.model.mobile];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneStr]];
5烛芬、類似微博主頁、簡(jiǎn)書主頁等效果飒责。多頁面嵌套赘娄,既可以上下滑動(dòng),也可以左右滑動(dòng)切換頁面宏蛉。支持HeaderView懸浮遣臼、支持下拉刷新、上拉加載更多拾并。https://github.com/pujiaxin33/JXPagingView 先保存一下 有時(shí)間學(xué)習(xí)學(xué)習(xí)
6揍堰、UIWebView打開相冊(cè)或者預(yù)覽時(shí)頂部會(huì)有遮擋,需要適配iOS11
if (@available(iOS 11, *)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
如果是使用UIImagePickerController嗅义,可以通過去除毛玻璃效果屏歹,_picker.navigationBar.translucent = NO;
7、UITextField實(shí)時(shí)監(jiān)測(cè)內(nèi)容有兩種方法:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *str = [textField.text stringByReplacingCharactersInRange:range withString:string];
str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"%@", str );
return YES;
}
或者
[textField addTarget:self action:@selector(textFieldEditChanged:) forControlEvents:UIControlEventEditingChanged];
代理方法
- (void)textFieldEditChanged:(UITextField *)textField
{
NSLog(@"textfield.text %@",textField.text);
}