mark 細節整理,記錄問題

2021-06-21 11:31:45 字數 2569 閱讀 4342

計算兩個日期之間相差幾天幾小時幾分鐘

用timeintervalsincedate得到日期之間相差的秒數,然後再轉換成天數小時和分

nscalendar *calendar = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar];

nsdatecomponents *comps = [[nsdatecomponents alloc] init];

nsinteger unitflags = nsyearcalendarunit | nsmonthcalendarunit | nsdaycalendarunit | nsweekdaycalendarunit |

nshourcalendarunit | nsminutecalendarunit | nssecondcalendarunit;

comps=[calendar components:unitflags fromdate:date todate:date options:0];

nslog(@"%@",comps);

// comps = [calendar components:unitflags fromdate:date];

nsdateformatter *dateformatter=[[nsdateformatter alloc] init];

[dateformatter setdateformat:@"yyyy-mm-dd hh:mm:ss"];

nsdate * senddate=[nsdate date];

//結束時間

nsdate *enddate = [dateformatter datefromstring:@"2014-6-24 00:00:00"];

//當前時間

nsdate *senderdate = [dateformatter datefromstring:[dateformatter stringfromdate:senddate]];

//得到相差秒數

nstimeinterval time=[enddate timeintervalsincedate:senderdate];

int days = ((int)time)/(3600*24);

int hours = ((int)time)%(3600*24)/3600;

int minute = ((int)time)%(3600*24)600/60;

if (days <= 0&&hours; <= 0&&minute; <= 0)

datecontent=@"0天0小時0分鐘";

else

datecontent=[[nsstring alloc] initwithformat:@"%i天%i小時%i分鐘",days,hours,minute];

nsindexpath *indexpath_1=[nsindexpath indexpathforrow:indepath.row insection:0];

nsarray *indexarray=[nsarray arraywithobject:indexpath_1];

[mytableview reloadrowsatindexpaths:indexarray withrowanimation:uitableviewrowanimationautomatic];

ios7裡面tableviewcell上面的分割線,左邊少了20個畫素,用下面的方法,可以讓分割線完整顯示出來

if ([_tableview respondstoselector:@selector(setseparatorinset:)])
1.在info.plist裡面新增字段

value---no

//uitextfielddelegate  

- (bool)textfieldshouldreturn:(uitextfield *)textfield;

- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string // return no to not change text

nscharacterset *cs;

cs = [[nscharacterset charactersetwithcharactersinstring:kalphanum] invertedset];

nsstring *filtered =

[[string componentsseparatedbycharactersinset:cs] componentsjoinedbystring:@""];

bool basic = [string isequaltostring:filtered];

return basic;

}

相關my.ipa設定需修改my.plist檔案

約瑟夫問題 mark

把問題重新描述一下 n個人 編號0 n 1 從0開始報數,報到 m 1 的自殺,剩下的人繼續從0開始報數。求最後自殺者的編號。n個人編號如下 第乙個自殺的人是 m 1 n,例如上圖中,41個人中,報到3的人自殺,則字乙個自殺的人的編號是 3 1 41 2。編號 m 1 n自殺後,剩下的人排列如下 將...

docker問題整理記錄

1 docker容器時區不是北京時間 1.1 直接修改容器系統時間 docker cp etc localtime 容器id etc localtime1.1.1 tomcat時間不是北京時間 jre是通過配置檔案讀取本地時間的 etc timezone 覆蓋容器配置資訊 docker cp etc...

測試細節整理

1.列表資料量比較大時,進入資料詳情介面,返回的列表介面需要停留在使用者之前停留的地方,否則體驗會很差,一般開發會設定為手動重新整理 eg 專案列表中存在很多個專案,假如使用者進入列表的第二頁,點選其中乙個專案,進入專案詳情介面,返回專案列表時,頁面停留在第二頁 2.搜尋記錄列表上下滑動進行重新整理...