Like button on wrong cell for UITableView after search - swift

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.

Related

How would I go about detecting links in TTTAttributedLabel?

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.

UISearchBar - what is "search results button" for?

(Duplicate of this question, but I figured I could try again, since that one wasn't answered...)
The UISearchBar on the iPhone has an option showsSearchResultsButton. When you turn it on, it shows a button with horizontal lines inside the search bar, and you can implement a callback that will be called when the user presses it.
The thing is, I can't find a single place on the Internet where it says what the intended purpose of this button is. I know I could make it do anything, but I'd like to know what it's actually for. Should it show a history of searches, or all items without filtering, or what?
It's simply to show search results when tapped.
Where Apple uses this is in their iPad App Store application. If you go to the Categories tab you'll see various app categories. Search for an item, you'll get a list of results, and when you press "Done" you are shown the categories screen again. Your previous search term is still listed in the search field, but now the Search Results Button appears in the field. After tapping this, a UIPopOver is displayed, showing a text list of the results from your last search.

"Load More" in UITableView

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.

iPhone SDK: How to detect a row-hit while in the editing mode?

I've looked everywhere and I can't find it.
I have a UITableView that contain rows of "checkmark" cells.
The user clicks on a row to check/uncheck it.
(It works!!!!)
But I also want to allow the user to EDIT the data on that row.
... so I have an "EDIT" button at the top. The user hits it and is allowed to DELETE any
rows. (That works too!!!!)
But how do I also detect a "tap" on that row.
Where is there some kind of a didSelectRowAtIndexPathWhileInEditMode ????
(Is that really the best way to do this: Allow "selections", and "deletions", and "editing" of each row?)
You should switch on allowsSelectionDuringEditing for UITableView from code or Interface Builder

Sending user to view from search results

I'd like to implement a search into my app. I'm planning to use a left swipe, like the Spotlight search. Would that violate anything with Apple?
My app is tableview based. The user can drill down a few levels before reaching a detail view. I'm considering two options for implementing the search:
1.) From the search results, I display lower level topics. Meaning, once a user clicks a search result, they will open a detail view. Should I back the user out of the search, navigate the UI down to the detail view...or just show the detail view (option #2)?
2.) If I just popup the detail view, it will be out of context. Once finished with the detail view, the user will not be able to navigate backwards to the top level. They will basically already be there (search results). Or is that how it should be - just put the user back on the search results view?
I don't know if it'd get rejected, but it sounds weird as I've never seen it in an app before. Why not just put the search bar in the first row of the table as in the iPod app?
You probably could also mimic the iPod behavior when "backing out" of Search results.
But yeah, this isn't really programming related.