Discussion Forums  >  Status Bar, Navigation Bar

Replies: 17    Views: 172

aur
buzztouch Evangelist
Profile
Posts: 5
Reg: May 29, 2013
bney brak
1,650
06/09/13 01:47 AM (7 years ago)

multiple buttons

is it possible add to the navigator bar more than one buttom, so it will be possible select more than one action (example: button 1:next button 2: back button 3: bookmark) ?
or instead of that how is it possible add buttons on an exists screen ?

regards,

aur
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/09/13 04:28 AM (7 years ago)
It is possible, with a little modification of your plugin code...

http://stackoverflow.com/questions/9897978/cant-assign-multiple-buttons-to-uinavigationitem-when-using-storyboard-with-ios

although it is explained with storyboards, the theory holds true for xibs or programmatic.

Cheers!

-- Smug
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
06/09/13 06:17 AM (7 years ago)
Yup exactly as smug said.

Keep in mind however you would have to link the screen manually and would not be able to change the screen link in the control panel - at least not with modifying more code then you probably want!

Cheers,

David
https://buzztouchmods.com
 
chris1
Code is Art
Profile
Posts: 3860
Reg: Aug 10, 2012
Oklahoma City, ...
50,100
like
06/09/13 06:47 AM (7 years ago)
There's been some forum posts about this, if you do a search. On my phone or I'd try to find the post for you
 
aur
buzztouch Evangelist
Profile
Posts: 5
Reg: May 29, 2013
bney brak
1,650
like
06/09/13 07:56 AM (7 years ago)
thank you all
it look a little complicated...
i will try what you suggest
also at the forum u didn't find any thing yet
regards
aur
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/09/13 09:29 AM (7 years ago)
The navbar buttons can either be right or left.
But you can add multiple right or left navbar buttons but ustilising an array

First off lets make a new button

UIBarButtonItem *yipee = [[UIBarButtonItem alloc] initWithTitle:@"Yipee" style:UIBarButtonItemStylePlain target:nil action:@selector(yipeeAlert)];

nice and simple we have made a barbutton called yippee. it's got a title "yipee" it's a normal plain button, no target and it fires a method when clicked called yipeeAlert.


Let's make an array for our happy buttons

NSMutableArray* navBarButtons = [[NSMutableArray alloc] init];

we've called it navBarButtons and we've made it mutable as we may add or remove

Okay let's add a button the first button will be the right most and work in.

[navBarButtons addObject:yipee]; //notice yipee is the name of our new button

Here's were the mutable bit comes in, Buzztouch gives us a cheeky hard coded right nav button, but it is not always used so we put an if statement before adding it.

//there isn't always a rightnavbarbutton in the control panel so we check before adding
if(self.navigationItem.rightBarButtonItem != nil){
[navBarButtons addObject:self.navigationItem.rightBarButtonItem];
}

The if statement asks do we have a rightnavbarbutton is NOT blank then lets add it.

Note BT rightnavbar button is called ALWAYS rightBarButtonItem



Then we point are navbar at the selection of right bar buttons

self.navigationItem.rightBarButtonItems = navBarButtons;


This altogether looks like this and should be added to the end of the viewwillappear method

UIBarButtonItem *yipee = [[UIBarButtonItem alloc] initWithTitle:@"Yipee" style:UIBarButtonItemStylePlain target:nil action:@selector(yipeeAlert)];
NSMutableArray* navBarButtons = [[NSMutableArray alloc] init];
[navBarButtons addObject:yipee];
//there isn't always a rightnavbarbutton in the control panel so we check before adding
if(self.navigationItem.rightBarButtonItem != nil){
[navBarButtons addObject:self.navigationItem.rightBarButtonItem];
}


self.navigationItem.rightBarButtonItems = navBarButtons;


To test it works we need that yipeeAlert method add this outside any other methods

-(void)yipeeAlert{
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Yipee"
message:@"I created an extra UIBarButtonItem"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}


Obviously yipee alert could be anything, open new screen, go back, show camera, turn flash light eta.
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 10:31 AM (7 years ago)
Kittsy to the rescue. Again!
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 12:51 PM (7 years ago)
Maybe it's me, but when using this code with a BT rightBarButtonItem I lose the Yipee button and get double BT buttons when returning to the screen.
A manual refresh corrects the problem. Also, how would you put the yipee button to the left of the BT button?

Here is a screen capture to demo the problem:

https://dl.dropboxusercontent.com/u/16323370/yipee.mov

Thanks in advance :-)
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/09/13 01:34 PM (7 years ago)
Hi reddog I've just copy and pasted that into a buzz carousel view did appear and refreshed the app. did you put it at the end of the viewwillappear method

to change the order you add the objects the other way around so the yipee button would be last

UIBarButtonItem *yipee = [[UIBarButtonItem alloc] initWithTitle:@"Yipee" style:UIBarButtonItemStylePlain target:nil action:@selector(yipeeAlert)];
NSMutableArray* navBarButtons = [[NSMutableArray alloc] init];

//there isn't always a rightnavbarbutton in the control panel so we check before adding
if(self.navigationItem.rightBarButtonItem != nil){
[navBarButtons addObject:self.navigationItem.rightBarButtonItem];
}
[navBarButtons addObject:yipee];
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/09/13 01:48 PM (7 years ago)
Here's a vid as well so it show's I'm no lying lol

https://dl.dropboxusercontent.com/u/16651980/2013-06-09_21-42-53.mp4

Danny said he had an issue where multiple buttons where created, when I showed how to do this with Scringo. but I cannot replicate this.

Are you self hosted is this a bug on the server, I'm pretty sured everything is packaged up the same.

Ahh the mysteries of code
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 01:58 PM (7 years ago)
As far down as it will run. Just before:
//////////////////////////////////////////////////////////////
//UITableView delegate methods

In the BT_screen_menulist_simple.m
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 02:00 PM (7 years ago)
Yep. Self hosted.

No worries, I don't need multiple buttons at this time. I can try to figure it out later.
Go enjoy your Sunday. It's about over for you.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/09/13 02:01 PM (7 years ago)
that's the layout method here's what it should look like

//view will appear
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[BT_debugger showIt:self theMessage:@"viewWillAppear"];

//flag this as the current screen
myApp_appDelegate *appDelegate = (myApp_appDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.rootApp.currentScreenData = self.screenData;

//setup navigation bar and background
[BT_viewUtilities configureBackgroundAndNavBar:self theScreenData:[self screenData]];

//if we have not yet inited data..
if(self.didInit == 0){
[self performSelector:(@selector(loadData)) withObject:nil afterDelay:0.1];
[self setDidInit:1];
}

//show adView?
if([[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"includeAds" defaultValue:@"0"] isEqualToString:@"1"]){
[self showHideAdView];
}
UIBarButtonItem *yipee = [[UIBarButtonItem alloc] initWithTitle:@"Yipee" style:UIBarButtonItemStylePlain target:nil action:@selector(yipeeAlert)];
NSMutableArray* navBarButtons = [[NSMutableArray alloc] init];
[navBarButtons addObject:yipee];
//there isn't always a rightnavbarbutton in the control panel so we check before adding
if(self.navigationItem.rightBarButtonItem != nil){
[navBarButtons addObject:self.navigationItem.rightBarButtonItem];
}


self.navigationItem.rightBarButtonItems = navBarButtons;

}
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 02:03 PM (7 years ago)
Does your buzz Carousel auto refresh when it is loaded?
Maybe the simple menu does not?
Just thinking out loud :-)
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/09/13 02:04 PM (7 years ago)
you've added it to the wrong method see my last post
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 02:11 PM (7 years ago)
You were right (as usual).

I kept moving the code lower and lower. I thought I started in view will appear but I was in
load data area. (dope).
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
06/09/13 02:14 PM (7 years ago)
At least all this back-and-forth put me in the Top 25 posters, haha.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/09/13 02:23 PM (7 years ago)
Phew wouldn't of been able to sleep thinking I'd give duff code out.

Congrats on the top 25
 

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.