I am coding a tableview with users posts to display. I am currently trying to break it into to sections to where the first section consist of the posts by users and the second section consists of a spinner cell that loads more posts. I keep getting a small error in my code shown here. If anyone can explain why I am getting this issue when I have never had this issue when running similar code. Thank you.
I'm not quite sure what you are asking but I think I still might be able to help. I am currently working on a project with a table view also. I would try creating a variable or some other data type that contains the specific cells you want to be in that section. I would use indexPath.row to add these cells to that variable. I would then try running an if statement with that variable that contains those specific cells and then running the code based on that.
If indexPath.section == 0 {
...
}
Related
I’m doing my first app using VIPER. The app is from Marvel and it basically shows the details of a selected character from a list of characters fetched from Marvel’s api. So far I’ve successfully been able to show the collection of characters (with pagination). The problem comes when I want to see the details of a selected character. The list of characters can be seen in image 01.
When the DetailsViewController is opened, I want to show (for the moment) just the name of the character (in the view title), the character’s image and the description.
The Details View is a table view divided in 3 sections: character’s image, character’s description and character’s bibliography (see image 02).
In my viewController class, I am fetching the character’s details through the view’s presenter (see Image 03) but I have noticed the the flow of the code is NOT executing first the viewWill Appear, but the cellForRowAt code (image 04).
This causes that the code fails in the Presenter since of course there is no viewModel (see image 05, line of code 71). I think it may be a problem with an asynchronous call, but I haven’t been able to find where do I have to call the Dispatchqueue.main.async to reload the tableView of my view (calling the reloadData from the Presenter).
So I’m coming to you to get some guidance since I am kind of lost and honestly I don’t know what to do.
So my question is: how can I execute first the code of viewWillAppear to have a viewModel and then load the cellForRowAt to show the details of that cell?
I appreciate in advance any help you can provide me. In case you need me to show you the code of my interactor or provider I can share it, no problem for me.
Kind regards!
Image01: https://i.stack.imgur.com/qE7ue.png
Image02: https://i.stack.imgur.com/4X2cW.png
Image03: https://i.stack.imgur.com/qXokv.png
Image04: https://i.stack.imgur.com/SfX8N.png
Image05: https://i.stack.imgur.com/0xoLv.png
I visually designed a table in storyboard, which displays six properties of an object. I can see the table in the visual editor, but for some reason, when I run the app, the table is not there.
Do I have to initialize anything, or ... ?
Here is screenshot
I know this is an old question. But I ran across the same problem and thought I would share the solution I found. When using the storyboard UITableViewController the implementation file autofills with methods and delegates for UITable. However, if you are using static cells you need to remove all of the implementation file table data source defaults (ie. numberOfSectionsInTableView, numberOfRowsInSection, cellForRowAtIndexPath)
i want to create a grouptableview for my application in which some section are editable and some are checkedmark can any body tell me in details to how i do this ,
i want to put content in row like 'placeholder in textbox'.
I have tried many times and search in google bt i m nt getting any idea please help to out this issues.
i want to create grouptableview like this image for my application.
!Screen shot
If you want to edit the content of cell, you have to add UITextField/UITextView to the cell. You can very well assign a placeHolder for the UITextField/UITextView. Refer this SO Post.
For check mark you can use default cell by toggling its accessoryType between UITableViewCellAccessoryCheckmark and UITableViewCellAccessoryNone.
based on your noofsections you can create the no of groups.
Any code examples for using a UITableView to implement in-app settings?
That is where to get the iPhone settings app look and feel one custom builds the settings into a UITableView. So you you would custom set the sections and cells that get returned with switch type statements.
In particular interested in reviewing the coding approach for how to:
best configure the cellForRowAtIndexPath and didSelectRowAtIndexPath
how to handle those cells for which you want in cell editing (e.g. text)
those cells where you need to launch off into another screen to set a date/time for example
how to collect up parameters and pass back to calling rootViewController (in my case need to persist data out to Core Data persistence)
Note: using Core Data so not interested in using libraries such as InAppSettings [any feedback re whether such libraries might be ok appreciated at this SO question I created].
thanks
I am not sure if you can use the inappsettingskit for your needs. It is open source so you are free to modify the code as you wish, but it doesn't look as an out of the box solution.
If you want to make these settings available in the settings app you will have to live with some workarounds for example saving NSDate AND getting a nice UI control to modify it: Use a textfield, there is no control specified which let's you pick a date. Have a look at Apple's documentation.
So the last option will be coding. First of all, determine what kind of types you want to support. Then create custom TableViewCells which reflect those kinds. If some kinds do need some special way of editing, for example a color picker, you'll have to write those controllers as well. You set a cell into editing mode with the delegate method tableView:didSelectRowAtIndexPath and present the custom controller or get into editing directly for example a UITextField. A Slider is handled directly without any coding.
The cells will need some kind of identifier so you can identify those in your model. A TableView and Core Data can interact with each other pretty well by using the NSFetchedResultsController. Create a simple window based app with a template and check the Use Core Data for Storage. The rootViewController illustrates how a tableView works together with Core Data. For your case it will be getting a bit more complicated as inserting a row will have to determine what kind of cell it should add.
I think you should look into this and get back with some more specific questions.
I am loading the custom cell on tableView and i return 50 rows in the tableView.
number of some rows are display in the tableview but when scroll the tableview my customcell is not display and I have the error
"EXC_BAD_ACCESS"
and also display following message on the console
"void SendDelegateMessage(NSInvocation*): delegate (webViewDidLayout:) failed to return after waiting 10 seconds. main run loop mode: UITrackingRunLoopMode"
I think you get this error due to your method of making custom cells. When you made the class file for the custom cell in the .m file you released the IBOutlets. Try removing that portion from your code than try.
I had the same problem in an app, and I solved that problem this way. Maybe this solution will work for you too.
The best way to detect zombies is:
in the Groups and Files section,
expand the Executables section
and right click on your app name and
choose Get Info
select the Arguments tab on the top and then add a new entry in the Variables to be set in the environment section. Name the new variable to NSZombieEnabled and set its value to YES.
After this you will have information in console on which released objects you make calls.
This typically means that you have asked the program to look at a memory area that you don't have access to, which usually means you have run off the end of an array, or something.
If you are running in debug mode, the stack trace will probably give you more clues. Open up the debug console.
You should also use NSZombieEnabled, it usually helps. It shows you which deallocated object was accessed. Be sure to disable it after you use it because using this, no memory is ever released.