iOS 11問題..持續(xù)更新

開發(fā)過程中的一些以前遇到的一些問題和新遇到的iOS11的問題,會(huì)持續(xù)更新,,后邊會(huì)附上自己寫的一些小工具,希望可以幫助到其他盆友們,順便求打賞?(? ? ??)嘿嘿

0.0.jpg

iOS11

1.nav.title顯示數(shù)字標(biāo)題時(shí),顯示紊亂

在標(biāo)題上邊只顯示的是數(shù)字,就不會(huì)正常顯示,會(huì)遮擋.暫時(shí)沒有太好的解決辦法,我的處理方法就很簡單:

UILabel *navTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
navTitleLabel.backgroundColor = [UIColor whiteColor];
navTitleLabel.font = [UIFont fontWithName:@"PingFangTC-Light" size:17];
navTitleLabel.textColor = [UIColor blackColor];
navTitleLabel.textAlignment = NSTextAlignmentCenter;
navTitleLabel.text = self.title;
self.navigationItem.titleView = navTitleLabel;

2.關(guān)于inputAccessoryView定制問題

iOS11已經(jīng)不能定制inputAccessoryView了,我們以前會(huì)有這樣一種用法:

self.testTF.inputView = self.pickerView//(UIPickerView);
self.testTF.inputAccessoryView = self.toolBar//(UIToolbar);

你會(huì)發(fā)現(xiàn)在iOS11上已經(jīng)不能這么用了,會(huì)失效,暫時(shí)的解決辦法只能自定義個(gè)view然后放置上UIPickerView再加倆button,拋出代理處理了.


普通問題

1.獲取父視圖控制器

- (UIViewController *)viewController
{
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
} 

2.解決cell頂格

-(void)viewDidLayoutSubviews
{
    if ([self.historySearch respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.historySearch setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
    }
   
    if ([self.historySearch respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.historySearch setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
    }
}
#pragma mark - UITableViewDelegate

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
   
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

3.報(bào)錯(cuò):BuildRoot :6520

[UITableView _dequeueReusableViewOfType:withIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/So 6520
cell上邊添加手勢出錯(cuò)

4.報(bào)錯(cuò):BuildRoot :6530

[UITableView _dequeueReusableViewOfType:withIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/So 6530
在可視化編程中view上多了一個(gè)不屬于當(dāng)前控制器的控件

5.iOS10跳轉(zhuǎn)APP store (alivegallery)這個(gè)是固定字段

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/alivegallery/id******?mt=8"]];

6.修改狀態(tài)欄顏色

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

方法不起作用:

  • 查看info文件中是否有View controller-based status bar appearance 設(shè)置的是NO 有的話把其刪除
  • 刪除完之后再重寫一個(gè)自己的nav作為根nav
  • 然后重寫nav中的上述方法,方法實(shí)現(xiàn):
- (UIStatusBarStyle)preferredStatusBarStyle
{
    UIViewController* topVC = self.topViewController;
    return [topVC preferredStatusBarStyle];
}

//注意 設(shè)置完這個(gè)之后整個(gè)項(xiàng)目self.automaticallyAdjustsScrollViewInsets會(huì)默認(rèn)為yes,注意布局

7.收回當(dāng)前控制器成為第一響應(yīng)者的view

- (void)viewResignFirstResponse:(UIView *)view {
    for (UIView *subview in view.subviews) {
        if ([subview isFirstResponder]) {
            [subview resignFirstResponder];
            return;
        }
        [self viewResignFirstResponse:subview];
    }

8.遇到引用庫重復(fù)定義的問題.

  • 拉出.a文件,查看.a文件支持的框架(arm64/armv7/i386/x86_64)
    lipo -info ***.a
  • 分解出各個(gè)單獨(dú)框架的.a文件(分解成not fat file 文件方便以后分離.o文件)
    lipo ***.a -thin armv7 -output ***_armv7.a (armv7例子)
  • 分解出各個(gè).a文件的.o文件(最好單獨(dú)創(chuàng)建一個(gè)文件夾)
    ar vx ***_armv7.a
  • 根據(jù)報(bào)錯(cuò)信息,刪除各個(gè)單獨(dú).a文件中沖突的.o文件(舉例)
    rm ********.o
  • 合并各個(gè)刪除.o文件之后的單獨(dú)框架 生成新的.a文件
    ````ar rcs ***_final_armv7.a *.o```
  • 其他單獨(dú)框架重復(fù)以上操作生成各種新的.a文件
  • 生成新的.a文件
    lipo -create ***armv7.a ***arm64.a ***i386.a ***x_86_64.a -output ***new.a
  • 覆蓋原工程中.a文件

9.解決在標(biāo)簽控制器上添加圖片被系統(tǒng)背景覆蓋問題

cinema.tabBarItem.image = [[UIImage imageNamed:@"cinema"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

后邊附上我近些時(shí)候?qū)懙囊粋€(gè)幫助類項(xiàng)目,算是一個(gè)在開發(fā)過程中使用到的小工具總結(jié),有一些也是自己寫的一個(gè)分類/擴(kuò)展,希望對你們有幫助


項(xiàng)目目錄:

分類&擴(kuò)展

  • ViewControl
//回收當(dāng)前鍵盤
- (void)viewResignFirstResponse:(UIView *)view;
  • View

獲取各種坐標(biāo)和frame的封裝(引用自網(wǎng)絡(luò))

  • String
//獲取字符串高度/寬度
- (CGFloat)boundingHeightWithWidth:(CGFloat)width withFont:(CGFloat)font;
- (CGFloat)boundingWidthWithHeight:(CGFloat)height withFont:(CGFloat)font;
//對象轉(zhuǎn)json字符串
+ (NSString*)DataTOjsonString:(id)object;
//emoji表情封裝(引用于網(wǎng)絡(luò))
NSString+Emoji
//數(shù)字和字母的集合
+ (Boolean)isNumberCharaterString:(NSString *)str;
//字母的集合
+ (Boolean)isCharaterString:(NSString *)str;
//數(shù)字組合
+ (Boolean)isNumberString:(NSString *)str;
//是否含有非法字符
+ (Boolean)hasillegalString:(NSString *)str;
//數(shù)字組合 +
+ (Boolean)isValidSmsString:(NSString *)str;
//郵箱
+ (BOOL) validateEmail:(NSString *)email;
//手機(jī)號(hào)碼驗(yàn)證
+ (BOOL) validateMobile:(NSString *)mobile;
//車牌號(hào)驗(yàn)證
+ (BOOL) validateCarNo:(NSString *)carNo;
//車型
+ (BOOL) validateCarType:(NSString *)CarType;
//用戶名
+ (BOOL) validateUserName:(NSString *)name;
//密碼
+ (BOOL) validatePassword:(NSString *)passWord;
//昵稱
+ (BOOL) validateNickname:(NSString *)nickname;
//身份證號(hào)
+ (BOOL) validateIdentityCard: (NSString *)identityCard;
//Urlencode轉(zhuǎn)碼
+ (NSString *)encodeToPercentEscapeString: (NSString *) input;
+ (NSString *)decodeString:(NSString*)encodedString;
  • Color
/* 從十六進(jìn)制字符串獲取顏色 */
+ (UIColor *)colorWithHexString:(NSString *)color;

/* 從十六進(jìn)制字符串獲取顏色 */
+ (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha;

/* 顏色轉(zhuǎn)圖片 */
+ (UIImage *)createImageWithColor:(UIColor *)color;
  • Date
//根據(jù)N年N月N日N時(shí)N分N秒生成日期 起始日期:0000-00-00 00:00:00 +0000
+ (NSDate *)dateWithYear:(NSInteger)year
                   month:(NSInteger)month
                     day:(NSInteger)day
                    hour:(NSInteger)hour
                  minute:(NSInteger)minute
                  second:(NSInteger)second;
//計(jì)算連個(gè)date之間差天數(shù)
+ (NSInteger)daysOffsetBetweenStartDate:(NSDate *)startDate endDate:(NSDate *)endDate;
//距今天之前N小時(shí)N分鐘的日期
+ (NSDate *)dateWithHour:(int)hour
                  minute:(int)minute;

#pragma mark - Getter
- (NSInteger)year;//到今天有多少年
- (NSInteger)month;//到今天有多少月
- (NSInteger)day;//到今天有多少日
- (NSInteger)hour;//到今天有多少小時(shí)
- (NSInteger)minute;//到今天有多少分鐘
- (NSInteger)second;//到今天有多少秒
- (NSString *)weekday;//今天是周幾


#pragma mark - Time string
- (NSString *)timeHourMinute;//獲取現(xiàn)在時(shí)間(14:05)
- (NSString *)timeHourMinuteWithPrefix;//獲取現(xiàn)在時(shí)間(下午14:05)
- (NSString *)timeHourMinuteWithSuffix;//獲取現(xiàn)在時(shí)間(pm14:05)
- (NSString *)timeHourMinuteWithPrefix:(BOOL)enablePrefix suffix:(BOOL)enableSuffix;

#pragma mark - Date String
- (NSString *)stringTime;//(14:05)
- (NSString *)stringMonthDay;//(08.25)
- (NSString *)stringYearMonthDay;//(2017-08-25)
- (NSString *)stringYearMonthDayHourMinuteSecond;//2017-08-25 14:05:30
+ (NSString *)stringYearMonthDayWithDate:(NSDate *)date;      //date為空時(shí)返回的是當(dāng)前年月日 獲取時(shí)間對象的年月日
+ (NSString *)stringLoacalDate;//獲取當(dāng)?shù)貢r(shí)間

#pragma mark - Date formate
+ (NSString *)dateFormatString;//yyyy-MM-dd
+ (NSString *)timeFormatString;//HH:mm:ss
+ (NSString *)timestampFormatString;//yyyy-MM-dd HH:mm:ss
+ (NSString *)timestampFormatStringSubSeconds;//yyyy-MM-dd HH:mm

#pragma mark - Date adjust
- (NSDate *) dateByAddingDays: (NSInteger) dDays;//從調(diào)用日期幾天之后的時(shí)間
- (NSDate *) dateBySubtractingDays: (NSInteger) dDays;//從調(diào)用日期幾天之前的時(shí)間

#pragma mark - Relative dates from the date
+ (NSDate *) dateTomorrow;//明天日期
+ (NSDate *) dateYesterday;//昨天日期
+ (NSDate *) dateWithDaysFromNow: (NSInteger) days;//從今天起幾天之后時(shí)間
+ (NSDate *) dateWithDaysBeforeNow: (NSInteger) days;//從今天起幾天之前時(shí)間
+ (NSDate *) dateWithHoursFromNow: (NSInteger) dHours;//從今天起幾小時(shí)之后時(shí)間
+ (NSDate *) dateWithHoursBeforeNow: (NSInteger) dHours;//從今天起幾小時(shí)之前時(shí)間
+ (NSDate *) dateWithMinutesFromNow: (NSInteger) dMinutes;//從今天起幾分鐘之后時(shí)間
+ (NSDate *) dateWithMinutesBeforeNow: (NSInteger) dMinutes;//從今天起幾分鐘之前時(shí)間
+ (NSDate *) dateStandardFormatTimeZeroWithDate: (NSDate *) aDate;  //標(biāo)準(zhǔn)格式的零點(diǎn)日期
- (NSInteger) daysBetweenCurrentDateAndDate;                     //負(fù)數(shù)為過去,正數(shù)為未來

#pragma mark - Date compare
- (BOOL)isEqualToDateIgnoringTime: (NSDate *) aDate;//兩個(gè)日期是否相等
- (NSString *)stringYearMonthDayCompareToday;//返回“今天”,“明天”,“昨天”,或年月日
+ (NSString *)intervalTimeFromDate:(NSDate *)date1 toDate:(NSDate *)date2;//返回 幾秒前,幾分前,幾小時(shí)前,幾天前,幾月前,幾年前
+ (NSString  *)displayDataStyleWithNumber:(NSString *)timeNumber;//通過時(shí)間戳 獲取"剛剛""幾分鐘前""幾小時(shí)前" "昨天 00:00:00" 本周內(nèi)"周幾" 超出本周"正常時(shí)間"
+ (NSString *)getTimeString:(NSInteger)duration; //通過時(shí)長獲取時(shí)分秒的字符串  倒計(jì)時(shí)用
#pragma mark - Date and string convert
+ (NSDate *)dateFromString:(NSString *)string;//字符串轉(zhuǎn)Date
+ (NSDate *)dateFromString:(NSString *)string withFormat:(NSString *)format;//根據(jù)格式把字符串轉(zhuǎn)成Date
- (NSString *)string;//日期轉(zhuǎn)字符串
- (NSString *)stringCutSeconds;//轉(zhuǎn)成字符串 砍掉秒  2017-08-25 14:05

還有一些幫助類:比如base64,MD5加密,des3加密,自己寫的一個(gè)金額輸入框例:"0.01",包括自主判斷和自定義鍵盤.一個(gè)無數(shù)據(jù)tabview(繼承)等等...

附上github鏈接,歡迎使用


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • *面試心聲:其實(shí)這些題本人都沒怎么背,但是在上海 兩周半 面了大約10家 收到差不多3個(gè)offer,總結(jié)起來就是把...
    Dove_iOS閱讀 27,579評(píng)論 30 472
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,741評(píng)論 25 709
  • 躺在床上睡不著。 本來打算八點(diǎn)睡得,結(jié)果一直到凌晨還是睡不著。 手機(jī)那頭,沒有回復(fù)的消息。 米決定再把那個(gè)人發(fā)的語...
    西瓜米閱讀 233評(píng)論 0 0
  • 浦沿學(xué)前教育集團(tuán)聯(lián)莊分園圍棋俱樂部開班啦!圍棋俱樂部由中大班的24名幼兒組成。幼兒園聘請了經(jīng)驗(yàn)豐富的專業(yè)圍...
    加加加佳閱讀 217評(píng)論 0 0
  • 烏魯木齊與我們青島有兩個(gè)小時(shí)的時(shí)差,晚上9點(diǎn)多鐘,天才剛剛黑。上班一族正在回家的路上,大街上車水馬龍,熱鬧非凡。...
    青潤閱讀 660評(píng)論 1 3

友情鏈接更多精彩內(nèi)容