us_david
Code is Art
Profile
Posts: 41
Reg: Dec 27, 2010
San Francisco
410
09/09/13 04:11 PM (10 years ago)

Action of a Right Side Nav Button

Hello, I am working on a project in which I need make one of the screen's right nav button connect to a custom PHP url WITHOUT showing an intermediate customer URL screen. How can it be done? Feng
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/09/13 04:17 PM (10 years ago)
Couldn't you have it connect to a custom URL plugin with your clients PHP file as the destination? Cheers! -- Smug
 
us_david
Code is Art
Profile
Posts: 41
Reg: Dec 27, 2010
San Francisco
410
like
09/09/13 11:34 PM (10 years ago)
What you suggested is what normally people do: Click on Right Nav Action Button -> Goes to a Custom URL screen which has a php associated with it. This is not What I want to achieve. I need: Click on Right Nav Action Button -> Runs a php script and does some work then return to current screen. As you can see there is no screen change in between. Does it make sense to you? Thanks for your reply! Feng
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/10/13 05:36 AM (10 years ago)
Ah. Gotcha. Possibly this could work? Have the rightNavButton take you to another customURL plugin, with your php script as the web address? That would call the script, and display the output. Maybe...? Not sure what your end goal is, so I can't suggest many possibilities. But 'typically' in an iOS project, things move from screen to screen. Cheers! -- Smug
 
us_david
Code is Art
Profile
Posts: 41
Reg: Dec 27, 2010
San Francisco
410
like
09/11/13 03:13 AM (10 years ago)
Hi Smug, This is what I did. Some more details about What I am trying to achieve: I have a BTM RSS screen with a right nav button. Once the button is selected I want to add the BTM RSS screen's RSS to the favorite list. Here is the problem: I have the right nav button hooked to a custom URL screen with a data URL such as http://www.domain.com/php/add_tofavorite.php?screenId=[screenId]. I intended to get screen ID of the BTM RSS screen so I can update the BT_item record. But I ended up getting screen id of the Custom URL plugin screen! So I was wondering is a right nav button would allow to be hooked up to a URL directly so I can get the right screen ID. Hope this clarifies a little bit more. Any help & suggestions on how it can be done? Feng
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/11/13 04:00 AM (10 years ago)
Not entirely sure if I understand.... Lets say your current screen is the RSS Plugin. The person likes this feed, and wants to keep it in their favorites. The right NavButton is the button they press to save to favorites. They press the button (which, on the back end, does stuff to save it to favorites). Your desired result is to provide some kind of positive feedback to the user that indeed the feed was saved to their favorites, yet you wish the user to remain on the current RSS Plugin. Is this correct? As a side question, do the favorites 'have' to be a php script on an online server? Have you thought about working with NSDefaults, and just have the button save the data locally? Cheers! -- Smug
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/11/13 04:45 AM (10 years ago)
Just a thought; Have you thought about forgetting the Buzztouch RightNavButton, and use your own? In the desired plugin (RSS?) in the 'viewDidLoad' method, add this code somewhere near the bottom... UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Do The Watusi" style:UIBarButtonItemStylePlain target:self action:@selector(doTheWatusi)]; self.navigationItem.rightBarButtonItem = anotherButton; [anotherButton release]; And then, outside of any existing method, add the method for your desired action: -(void)doTheWatusi { [BT_debugger showIt:self theMessage:@"did the Watusi"]; } Of course, you'll also end up having to write code to 'talk' with the server, so you might want to read up on NSURLConnection. http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/ Cheers! -- Smug
 
us_david
Code is Art
Profile
Posts: 41
Reg: Dec 27, 2010
San Francisco
410
like
09/12/13 08:28 PM (10 years ago)
I will give it a try and see how it works. I'll report the result here so others may be interested in it. Thanks! Feng
 
us_david
Code is Art
Profile
Posts: 41
Reg: Dec 27, 2010
San Francisco
410
like
09/15/13 08:33 PM (10 years ago)
" Of course, you'll also end up having to write code to 'talk' with the server, so you might want to read up on NSURLConnection. http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/ Cheers! -- Smug " I am wondering if I can use functionality in BT Core to achieve this? The similar function should be in BT core already. Feng
 
us_david
Code is Art
Profile
Posts: 41
Reg: Dec 27, 2010
San Francisco
410
like
09/18/13 01:08 AM (10 years ago)
Here is how the problem was resolved and I am postign it here hoping to help others if they need similar solution. Thanks to @Smug for his suggestions. 1) Create BT_rightButtonAction which is subclass of UIBarButtonItem; 2) Include in the button a BT_downloader ; 3) Register BT_rightButtonAction as the delegate for BT_downloader events; 4) BT_downloader is used to handle URL request to your PHP script. Here is a sample .h file for the button: @protocol BT_RightButtonActionDelegate <NSObject> @end @interface BT_RightButtonAction : UIBarButtonItem <BT_downloadFileDelegate> { id <BT_RightButtonActionDelegate> delegate; NSString *dataURL; BT_downloader *downloader; } @property (nonatomic, retain) NSString *dataURL; @property (nonatomic, retain) BT_downloader *downloader; -(id)initWithTitle:(NSString*)title target:(id)target dataURL:(NSString*)aURL; -(void)submitClick; -(void)setDelegate:(id <BT_RightButtonActionDelegate>)aDelegate; @end You can initialize it in a BT_viewcontroller class's viewDidLoad method(as suggested by @Smug): rightActionButton=[[BT_RightButtonAction alloc] initWithTitle:@"ButtonTitle" target:nil dataURL:[NSString stringWithFormat:@"http://www.example.com/response.php?command=setDefault&screenId=%@",[self.screenData itemId] ]]; Once the button is tapped, the URL will be visited: http://www.example.com/response.php?command=setDefault&screenId=[screenId] You can choose to have screenId passed over to access screen json data. Also suggested that your PHP to spit out json formatted response back. Hope it can be of some use to you... An interesting question is you are still reading: How to make this button a BT plugin... Cheers! Feng
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/18/13 02:33 AM (10 years ago)
This is pretty nice work, Feng! Well done! I'm copying this into my snippet library. Don't need it now, but you never know when. :) Cheers! -- Smug
 

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.