4 回答

TA貢獻1773條經(jīng)驗 獲得超3個贊
1.[self performSelector:@selector(函數(shù)名) withObject:nil afterDelay:5.0f]
條件:在uiviewController的主線程中
2.[NSTimerscheduledTimerWithTimeInterval:5.0f target:self selector:@selector(函數(shù)名) userInfo:nil repeats:NO];
在具體函數(shù)中,執(zhí)行代碼,執(zhí)行完畢以后調(diào)用NSTimer invalidate方法來銷毀timer
3.[NSThread sleepForTimeInterval:5.0f];
[要延遲執(zhí)行的方法];
條件:主線程或者子線程都可

TA貢獻2080條經(jīng)驗 獲得超4個贊
<html>
function a()
{ alert("aa"); }
function b()
{ a(); }
<body onload="window.setTimeout(b,5000);"></body>
</html>

TA貢獻1921條經(jīng)驗 獲得超9個贊
function a()
{ alert("aa"); }
function b()
{ setTimeout(a(),延遲時間); }
<body onloud="b()"></body>
- 4 回答
- 0 關(guān)注
- 1109 瀏覽
添加回答
舉報