UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Challenge 07 from HWS [UIKit] - can't edit text field

Forums > 100 Days of Swift

This is an attempt at doing the Milestone Projects 19-21 from HWS (the UIKit version).

The challenge is to recreate the Apple Notes app. I've got the basic setup working (the data model, extensions, a data manager).

Here's the code: https://github.com/rjhoover/testingTextField

The app basically works in that it can:

  • add a new default note
  • save notes to disk
  • load saved notes from disk into a UITableView
  • the user can click one of the rows and be taken to a screen where they can change the text of the note body -- but they can't edit the title text field

The UITextField in the NoteViewController (titleTextField), as far as I can tell, is set up correctly with a TextField object in the main storyboard and an IBOutlet from the storyboard to the NoteViewController.swift file. But, I'm not able to edit the title in the text field. The body UITextView works fine; it lets you change the text and will save it to disk, but for some reason it won't let you change the title text field.

I can't see anything wrong with the code or the storyboard, but I have limited experience with storyboards and UIKit.

Can anyone see what the problem is? I've been fighting over this for more than a day and all I can find online is around ten years old (and it's objc code).

I need help

3      

Hi, In the Main.storyboard go to your Note view controller scene select the Navigation Item and set Large Title to never, it seems to be getting in the way.

3      

Yes, as @Hectorcrdna said, it is NavigationBar that is placed above your textfield that prevents from interaction with it. You can change it either via storyboard or add this line in your NoteViewController -> in viewDidLoad navigationItem.largeTitleDisplayMode = .never. Or you can move texfield a bit down so that it is tappable.

3      

That worked! Wow, thanks so much to @Hectorcrdna and @ygeras

3      

Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.