I'm loading an RSS feed into a table view. I'm going to load 10 entries and then would like it say "Load More" in the last cell or somewhere below the last cell, so when the user clicks on Load More, the rest of the RSS feed gets loaded. Since the RSS comes off of my web site, I can program it to get the 10 or all entries on the server side (using a query string or something).
The question is how to render a table such that the last cell has a Load More link that the can clicked to call a method to load the rest of the feed (and then when the entire feed is loaded there is no more "Load More" link).
Due to the way that UITableView's work (i.e.: they request cells/cell content as required) what's the value in the 'load more' link? (Especially as you'll presumably need to load the RSS feed in its entirely anyway.)
In other words, shouldn't the act of the user scrolling the table view be sufficient?
It's also potentially a bit confusing from a User Interface perspective - would having a "load more" at the bottom load older posts or newer posts? Where would these posts appear? At the top of the view or the bottom? (I'm presuming that you're ordering the cells in "most recent first" order, as this probably makes sense if you're consuming a feed.)
Update
However, if you really want to do this I'd suggest initially making your data source only tell the UITableView that it has "n"+1 elements, the +1 being a cell that contains your "load more" text. (You could format the cell to look different, using the backgroundView method, etc. on the UITableViewCell you supply.)
When the user selects this final cell you'll need to capture this as per usual, work out if it's the fake "load more" cell and if so, tell the data source that it should reveal all of its contents to the UITableView. Then you can simply get the table view to reload itself (via the reloadData method) and all should be well.
Related
In my app, the users can like specific cells. Everything works perfectly up until I search for a specific post and like it. In the photos, I search up "Ghastly" which before searching and filtering is the 4'th cell.
So when I search it and like it during a search and then exit the searching, the cell that gets liked is always the first. Or, if I search a post that is the 3rd cell during searching, then the third cell in the main UITableView is liked. I want it to be to where I like a specific post, exit the search, and that same post shows like.
Once I close my app and start it again then the liked buttons are on the correct cells.
I am building an app, where i have loaded a PDF of 300 pages. This PDF has lot of content, which are added as keywords to the tableViewCell in another VC.
When i tap any cell from VC, it should navigate to the next VC, where i have a UIWebView which has the PDF.
Now the ask is, when i press this cell, the new VC directly should navigate to the given page where the information related to that keyword is present.
Any idea or points on how to show a given page in PDF will help.
Thanks.
Because you're dealing with web, it is hard to have native navigation. I know from web development experience that to navigate to a specific part of a website, you can use anchor points/tags. I'd recommend looking into those. With them, you can change the URL from somepagehere.com to somepagehere.com/#page-1 or somepagepagehere.com/#-2, etc. Then, with the the UITableView you can point directly to these anchor points.
Let me know if this helps!
From your questions, it seems like you have a 300 page PDF file from an online location and you gather all the menu in your table view and each cell has the same url pointing to the link of the PDF.
This is not a good practice on the first place. This means that you are reloading the PDF file again and again when user simply want to see contents from another menu. It's also extremely hard to deal with paging problem from a web view.
Instead, if your pdf is well formatted(meaning it has a menu page and when you click on them from Adobe PDF reader, it can jump to the page), simply use this PDF reader. It also provides you the menu by itself and you don't need to have a table view controller and a webview controller. Moreover, you just need to put PDF file in your main bundle and never need to download every time.
I have a table view and in some of the cells there are links, I want to be allow the user to click on these links and view them in a webView (which I have already made). I don't want to use the row selection event because there may be more than one link in the cell. I came across TTTAttributedLabel and think it will be ideal. I don't need to add any style to the text in the cell, I only need to detect the links and capture the click event to open up my webview.
Any help would be greatly appreciated.
It looks like you can assign a TTTAttributedLabelDelegate to a TTTAttributedLabel that will get call backs for when a user selects different link types, but no opportunity for you to capture them and open your own web view (which I think is what you're trying to accomplish).
Instead, you might wanna check out OHAttributedLabel. It's similar in functionality, but when a user clicks on one of the links in the label, it calls -(BOOL)attributedLabel:(OHAttributedLabel*)attributedLabel shouldFollowLink:(NSTextCheckingResult*)linkInfo on it's OHAttributedLabelDelegate, which gives you the opportunity to handle the link tap yourself if you return NO.
I have an app based on a tab bar and data retrieved from the Internet. The main tab shows a map and one of the other tabs shows incidents around the center point of the map displayed using a UITableView. If the user moves the map and then moves to the incidents page, I need to refresh the list of incidents displayed in the table. To do this I request the incidents in viewWillAppear:animated: and when that completes (asynchronously) I call the table view's reloadData method.
This works beautifully unless the user taps between the tabs quickly (e.g. display incidents, move to map, move map, move back to incidents, move back to map, etc.). At some point the incidents data source (an NSArray) is modified while the table view is trying to access it.
Here is a question that is similar:
UITableView Crashes if Data Source Is Updated During Scrolling
One of the solutions for that question describes a solution at a high level that is exactly what I want: Freeze the data source while the table is being updated. The thing I can't figure out, however, is when to unfreeze the data source. The problem is I can't find any way to be notified when the table is done being updated.
Any ideas? How do I freeze the data source while the table is being updated and then unfreeze it once the table is done being updated?
Although I'd really like to receive a notification when the table view is done accessing the data source, I found that my problem was due to modifying the data container from the work thread. The answer to this question led me to the solution:
Refreshing XML data and updating a UITableView
What I do now is fill a separate array in the worker thread and then perform a selector on the main thread to swap the updated data into the data container used by the table view.
The problem is I can't find any way to
be notified when the table is done
being updated.
I think you can assume that the data is done being loaded by checking in tableView:cellForRowAtIndexPath: to see if the last row has been loaded.
I haven't tested it, just making an assumption based on the API
I have a large data to be displayed in Tableview cell can anybody tell me how to show just 10 of them after click display button.
and then add more 10 when user click on load more button.
Thanks in advance.
In the "number of rows i in section method" return a integer wich initially is 10. When the "load more" button is clicked add 10 to the integer and reload tableview.
You need to go give this a try first. People here will be very willing to help, but this isn't a "code it for me for free" site.
Here's the idea: Load your 10 out of however many items into an array or NSDictionary or what have you. Initialize your table with the same number of rows as you have in that data object (in -tableView:numberOfRowsInSection:).
Then build a view in the .tableFooterView property that maybe reports on how many of the elements are being displayed out of how many, and has a button to load more. Attach a target to that button to call a function that loads the next 10, and calls -reloadData on your UITableView.