The easiest way to add numberOfRowsInTableView and cellForRowAtIndexPath methods are by clicking the fix button on the right side of the error message. Type 'ContactsViewController' does not conform to protocol 'UITableViewDataSource'. Do you want to add protocol stubs? contactsTableView.dataSource = selfĪt this stage, Xcode will show you an error telling that protocol methods are missing. Let the contactsTableView know where it’s data source protocol methods are implemented, in this case, contactsViewController and in other-words self.I will be setting the profile image reference names to the same as names so that I do not have to create a property for the profile image. Go to ContactsViewController.swift file → ViewDidLoad() method view.backgroundColor =.Let’s change it so that it’s working properly. When adding the root view controller manually, Xcode will set its background colour to black by default. window?.rootViewController = ContactsViewController() Finally, assign ContactsViewController as a root controller of it.Once the window object is created, make it visible by invoking makeKeyAndVisible() method on it.Create a window object by instantiating UIWindow() constructor and make it the screen size of the device using.Go to AppDelegate.swiftfile → didFinishLaunchingWithOptions() method.However, doing it manually will help you to understand the steps involved in the same process. Note: This class could be a subclass of UITableViewController instead of UIViewController that will hook everything to the TableView for us. In Xcode, go to File → New→ CocouTouch Class → name it ContactsViewController and make it a subclass of UIViewController. STEP #3: Set Root View Controller to the Window Object Get rid of its reference as well by going to the top level of the project folder → General Tab→ Deployment Info → Main Interface and clear the Main text.ĭelete the ViewController.swift file as well.Īt this stage, the Xcode does not have an entry point, meaning the project does not have a root view controller that it points to, which will normally appear first followed by the splash screen when you run the app. IOS 13 & Swift 5 – iOS App Development Bootcamp STEP #2: Get Rid of Storyboard In that case, you can skip the next two sections and jump right into Step #4: Create a Data Model. If you want to keep the Main.Storyboard, that’s okay, you can still follow along. Once the project is created, download the asset files in here and unzip it, then drag them into the Assets.Xcassets file.Īs I am going to build this app 100% programmatically, Main.Storyboard is not needed for this project. Then, choose a single view application and name it contactsapp and leave all other settings as is. STEP #10: Implement UITableViewDelegate Protocol MethodĬreate a project by opening Xcode and choose File → New → Project.STEP #9: Create Custom UITableViewCell Programmatically.STEP #8: Add UINavigationController to the View Controller.STEP #7: Implement UITableView DataSource Protocol Methods.STEP #6: Add AutoLayout Constraints to the UITableView.STEP #5: Add UITableView to the ContactViewController.STEP #4: Create Data Model Struct and Class Files.STEP #3: Set Root View Controller to the Window Object.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |