# Add new item page

## หน้าเพิ่ม Todo

หน้าเพิ่ม Todo item เราจะทำเป็นหน้าใหม่ที่เปิดขึ้นมาซ้อนหน้าแรก โดยเลื่อนจากด้านล่างมาด้านบน หน้าตาแบบนี้

![](/files/gNhlb98doaPOnzUEt2wV)

ให้เราลาก ViewController ใหม่ มาจาก Object Library วางลงใน Main.storyboard

จากนั้นเนื่องจากเราจะใช้วิธีแสดงซ้อนขึ้นมาบนหน้าแรก (Modal) เราจึงต้อง Embed In Navigation Controller แบบเดียวกับหน้าแรกเพื่อให้มี หัว Title ในหน้า Add และมีที่สำหรับปุ่ม Cancel และปุ่ม Done

{% hint style="info" %}
ลองไม่ Embed In Navigation Controller แล้วข้ามไปสร้าง Segue ตามหัวข้อถัดไปเลยจะเป็นอย่างไร และ Segue แบบ Show กับ Present Modally ต่างกันอย่างไร
{% endhint %}

![Embed In Navigation Controller](/files/Ju51ujfG0ArYOHcwxJ1I)

ให้เราตั้งชื่อ Title เป็น Add New Item

![](/files/JXLA452IRx8xUwjHvMbu)

ใส่ปุ่ม Cancel และ Done

![](/files/CQLJofOO8RryoevdnC2V)

## เชื่อมกับหน้าแรกด้วย Segue

หลังจากนั้นเราจะสร้างการเชื่อมโยงด้วย **Segue** ให้เรากด **ctrl ค้างไว้** คลิ๊กที่ปุ่ม + ในหน้าแรก**ลาก**มายัง Navigation Controller

เลือก Action Segue เป็น **Present Modally** ตั้ง **Identifier** ให้ **Segue** โดยคลิ๊กที่ segue ก่อนแล้วตั้ง identifier ใน Attributes Inspector เป็น **openAddItemSegue** (เราจะใช้ในภายหลัง)

![](/files/cuctxdAMUewa47YWjEe3)

รันแล้วลองกดปุ่ม + ในหน้าแรก

![](/files/q5VorWqKll7soHBFvuHn)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pakornpat.gitbook.io/ios-app/add-new-item-page.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
