#5 Solved1 To Do List-tableView&delegate

Stephen Huang
May 11, 2021

--

運用delegate傳送從自定義Cell頁面傳送Bool值回到tableViewController頁面

此篇文章參考彼得潘的Delegate解說

摘要部分程式碼如下(print僅用來分析程式碼作動之先後順序)

右上程式碼決定每個cell顯示的內容

將indexPath.row(代表這個array的第幾個項目)
傳送到Cell頁面中的Button IBAction
使其點擊按鈕時立即作動
並判斷點擊的按鈕所屬的cell是哪一個

參數checked為Bool
若checked為true,則回傳true到tableViewController頁面
若checked為false,則回傳false到tableViewController頁面
並置換相對應的Button圖片

以上便可完成打勾的功能。

完整程式如下:

Photo by Glenn Carstens-Peters on Unsplash

End

--

--

Stephen Huang
Stephen Huang

Written by Stephen Huang

Wish me luck on the way become iOS app developer!

No responses yet