Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 81

PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
04/01/14 11:44 PM (10 years ago)

Next step towards my map search...

Hi all, I may be a little closer but could definitely use some insight from the wise ones. There's an example of Sven customising a plugin last year by adding a search bar to it here: http://www.buzztouch.com/forum/thread.php?tid=A4EFFD4F12C0D797E8256AE&sortColumn=FT.id&sortUpDown=DESC&currentPage=2 - though I can't tell whether he ever got it to run or not. Regardless, he appears to have been successful in at least making a search bar appear. When I follow his initial steps, there's a mis-match between the way the search bar is implemented and the view type it's using, because I'm trying to put it on a map page which, according to Xcode, doesn't have a table View available, so it throws the error. Sven had it in an RSS plugin that must have used tables. Assuming that all the setup in the BT_screen_map.h file is ok (I'm not getting errors there), can anyone suggest what type of 'view' or other setup would be required instead of [self.myTableView setTableHeaderView:searchBar]; to get it showing in BT_screen_map.m? (I'll worry about getting the search bar functional after I get it to appear!!) Cheers Paddy.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/02/14 01:02 AM (10 years ago)
"Typically" the search bar is used in conjunction with a 'tableView' object. In my location menu, it's a tableView (like many of your menu plugins) and entering data 'drills' down the available choices from the contents of the tableView 'cells' (each 'item' is a cell). I got my code from here: http://iosmadesimple.blogspot.com/2012/12/table-search-display-tutorial.html And there are a few similar tutorials around… Good Luck, and let us know how you faire! Cheers! -- Smug
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/02/14 04:54 AM (10 years ago)
Thank Smug, I love those step by step tutorials, I can (usually) keep up with them. If you haven't stumbled across this before, this tutorial below looks scary to me, but probably exactly what I'm looking to do, with the addition of a user input text field (I was thinking the search bar, but that may not work to pass user text to filter external data via php.) Anyway, I reckon I'll try playing with this for a week or three and see what it does!! http://nscookbook.com/2013/03/ios-programming-recipe-16-populating-a-uitableview-with-data-from-the-web/ Wouldn't it make an awesome BT plugin? ;) Cheers Paddy.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/02/14 06:58 AM (10 years ago)
^ that is a nice tutorial, I've looked at it before. Tableviews are great to learn but doing it inside BT would be tricky for newer coders IMO. The problem is that a lot (if not all) tableview tutorials out there use XIB's and Storyboards. None of the existing BT screens/plugins with tableviews use those. Menu with Image and the Search Menu are all done in code, no XIB files or custom cell layout xibs. So you'll have to create the entire thing from scratch and subclass the UITableViewController as a BTViewController. Then you can use the UiTableviewDelegate and UITableviewDatasource delegates. I've built a few of these to for BT projects but none of them are on the market. I have one that is close I'm trying to finish up that will show an example of how to do this. Also note that tutorial is also pushing a detail view when you select a tablerow and that's more code I've yet to see in an existing BT Plugin with XIB files. That doesn't mean you can't drop a search bar into an existing BT plugin, but that will all be trail and error coding as there won't be any complete tutorials out there that show you how to do this. Primarily Search Bars are for screens with tableviews. That RSS plugin is a tableview. But this is the magic of coding - if you want that on a map screen it can be done if you set your mind to it.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
04/02/14 08:13 AM (10 years ago)
Hi, If you want to see an example of a searchbar in a bt plugin have a look at The Blog Pro Plugin. I implemented a searchbar in there..... Best Regards, Danny
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/02/14 04:12 PM (10 years ago)
Thanks guys. OK, now I'm really terrified!! I'm wondering whether I'm actually approaching this from the wrong direction. Most of the search functions I see (including in your Blog Pro plugin, Danny, and the tutorial you posted, Smug) are all searching tables that are already holding data within the app. Sometimes those tables have been populated with external data, sometimes not. But the data is already there in the table, and the search is filtering 'existing' data. I actually don't want to fill a table with data at all, or query data within a table. What I want to do is use a search bar - or something that maybe just LOOKS like a search bar - to pass a query to an external database via php, and return the results as JSON so I can load up a different set of map pins using that JSON. Here's what I have: I already have my initial 'automatic' map query and the subsequent detail view working well via php, JSON and html. It goes like this: for example, I'm in Seattle, my phone knows that so my app automatically gives me a map with Seattle data in it for x miles around me. Works beautifully. I even have an alternative "list view" for those same data, and a detail view for each data point formatted in a html plugin - and it's all php and JSON doing all this data retrieval and formatting for me. Here's what I want to build: My goal is now to be able to use a search bar device that sits at the top of the map screen as the input field for a new 'manual' query. So even though I'm in Seattle, I want to know what's in Austin TX, so I type Austin TX into the searchbar-looking-thingy and that would return a different result set on the map screen. So my 'search' is not searching anything already inside the app or in a table, it's just re-querying my database and returning map locations based on the search term entered by the user. I expect I'll pretty much be able to clone my php files, make a couple of changes and they'll still serve up the same type of content, only this time specific to Austin TX (or wherever the user chooses to search). Here's what I have done so far: I've successfully added a UISearchBar to the top of BT_screen_map using some code posted by Sven (see my first post in this thread). When I tap it, the keyboard comes up, then the app crashes and I don't know why. I am really wading in murky waters here! So.. before I tinker unnecessarily and go down a long path of coding heartbreak in UI land, when maybe I should be using something else instead... do you think I should be using something other than a search function within a table? A simple form field that looks like a UISearchBar but isn't? Can such a thing be built? ATRAIN53, you're absolutely right, I'm a novice, and I know that I definitely won't be the person to pioneer new coding approaches in BT, at least not for many years to come! If you're willing to share a bit more about what you're working on that would be awesome, as it sounds closer to what I'm looking for. I really appreciate everyone's thoughts. Sorry for the long post, but I figure if I can clearly explain what I'm trying to do - and not do - it might spark something out there. :) Cheers Paddy.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/03/14 08:41 AM (10 years ago)
I really haven't worked with UISearchbars enough to give you more specific answers. But what you're describing is something I've seen in tons of map based apps. Enter a location and press search and it will display map pins..... You are adding and maintaining all these locations that you want to be displayed on your map in your own database somewhere? Otherwise I'd think you' want to leverage the Gooogle Places API or maybe the Foursquare API data to show users points of interest, food, etc... I have an app called 'Lunchbox' that does exactly this. It doesn't display the results in a mapview but instead a custom UIColection view. It uses foursquare as the back end to populate that collection view. I don't see it on the app store so you could look at it, but I did find his post that shows a screenshot of it. http://aboutfoursquare.com/foursquare-food-pinterest-style/ I point that out so you can see that searchbar on the top. I believe that is a UITextField in that app and not a UIsearchbar. UITextfield is a control you could use instead of a UISearchbar. You could set up a UITextfield and put a UIButton next to it that runs some code based on the input of the textfield. Take a look at this as well. This control uses the Google API to display Points of Interest on a map. http://code4app.net/ios/Search-Map-POI/519ae4ff6803fa5f2400005f You could download that sample app and study it. I've been looking at it for a few weeks for a potential upcoming project. Great example of how to use the Google places API. This is also some older code that you might find interesting- http://homepages.ius.edu/RWISMAN/C490/html/Chapter%2025.htm That has a UITextfiled and a UIButton and MKMapview that are the 3 elements that you want to get working together.... What you are building sounds great and I look at this custom stuff two ways- 1) Use an existing BT plugin and mod it. The downside of this is that you have to reverse engineer it first so you understand the plugin before you can mod it. You won't be able to find help on StackOverflow or other ios dev help forums to mod the existing BT code. 2) Find an opensource sample project that is similar to what you want to build. Download it, study it and mod it to suit your needs. Once you do all that you can turn it into a new BT plugin and use it inside a BT project. I don't think my tableview project will do much to help here except probably confuse you more. You've got the right approach to this, you don't seem afraid to tinker with code and that's what will get you to where you need to be.
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/03/14 01:26 PM (10 years ago)
Thanks ATRAIN53, I really appreciate your advice. And the foursquare thing opens up even more possibilities in other areas of what I envisage for my app! <squirrel!> Yes, all the locations are maintained on my own database. I think the answer might be somewhere in this bit "UITextfield is a control you could use instead of a UISearchbar. You could set up a UITextfield and put a UIButton next to it that runs some code based on the input of the textfield. ". That way the search term could get passed to php as the search variable. And that third link you have put up seems really close. I'll spend some time over the weekend and see what I can break. :) Cheers Paddy
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
04/04/14 05:51 AM (10 years ago)
Take a look at this Open Source iOS Helper Library For Working With The Google Directions, Map And Places APIs It is an extensive open source library greatly simplifying performing common tasks when using the Google Maps, Directions, and Places APIs. I found it on ManiacDev, I have not yet tried it. http://maniacdev.com/2014/04/open-source-ios-helper-library-for-working-with-the-google-directions-map-and-places-apis -- Niraj
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
04/05/14 03:03 AM (10 years ago)
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/07/14 11:27 PM (10 years ago)
Thanks Niraj & Danny, good stuff in there! Up goes the learning curve, one more time! (...and definitely not the last time that will happen!!) Cheers Paddy
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.