[英]How can I find out whether the user pressed the Call or the Cancel button when making a call from my app?
[英]How can I cancel or stop thread when back button is pressed?
我最近幾天一直在使用線程。我想在按導航欄中的后退按鈕時停止線程。但是我找不到停止該后台線程的解決方案。如果有人知道,請幫幫我。
如果您這樣做是在后台運行功能,即
[self performSelectorInBackground:@selector(myFunction) withObject:nil];
然后要取消它,您可以使用此代碼
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(myFunction) object:nil];
您可以NSOperation
並輪詢isCancelled
屬性以停止線程運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.