iphone - rightbarbuttonitem not showing up? -


note: can work switching leftbarbuttonitem rightbarbutton item in barbutton , barbutton2 methods. i'm curious know why won't work normally!

for strange reason, leftbarbuttonitem showing, rightbarbuttonitem never pops up! here's code

 -(void)barbutton { image = [uiimage imagenamed:@"bbut.png"]; uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; [button setbackgroundimage: [image stretchableimagewithleftcapwidth:7.0 topcapheight:0.0] forstate:uicontrolstatenormal]; [button setbackgroundimage: [[uiimage imagenamed: @"bbut.png"] stretchableimagewithleftcapwidth:7.0 topcapheight:0.0] forstate:uicontrolstatehighlighted]; [button addtarget:self action:@selector(showlocations:) forcontrolevents:uicontroleventtouchupinside]; button.frame= cgrectmake(3.0, 0.0, image.size.width+1, image.size.height+0); uiview *v=[[uiview alloc] initwithframe:cgrectmake(3.0, 0.0, image.size.width+1, image.size.height) ]; [v addsubview:button]; uibarbuttonitem *modal = [[uibarbuttonitem alloc] initwithcustomview:v]; self.navigation.leftbarbuttonitem = modal; -(void)barbutton2 { image2 = [uiimage imagenamed:@"refresh.png"]; uibutton *button2 = [uibutton buttonwithtype:uibuttontypecustom]; [button2 setbackgroundimage: [image2 stretchableimagewithleftcapwidth:0.0 topcapheight:0.0] forstate:uicontrolstatenormal]; [button2 setbackgroundimage: [[uiimage imagenamed: @"refresh.png"] stretchableimagewithleftcapwidth:0.0 topcapheight:0.0] forstate:uicontrolstatehighlighted]; // [button2 addtarget:self action:@selector(viewdidload) forcontrolevents:uicontroleventtouchupinside]; button2.frame= cgrectmake(281.0, 5.0, image2.size.width, image2.size.height); uiview *v2=[[uiview alloc] initwithframe:cgrectmake(281.0, 5.0, image2.size.width, image2.size.height) ]; [v2 addsubview:button2]; uibarbuttonitem *refresh = [[uibarbuttonitem alloc] initwithcustomview:v2]; self.navigation.rightbarbuttonitem = refresh; nslog(@"the action has been recieved!"); } 

in viewdidload method, have this:

[self barbutton2]; [self barbutton]; 

the action go through , receive nslog method. know why happening? left bar button shows , if change the first barbutton rightbarbuttonitem , change barbutton2 leftbarbutton item, , change cgrect coords, works, , that's i'm using right work, why happening? in advance.

you don't see right button because drawing outside screen.

the button2 x coordinate set 281.0 , parent view x coordinate set @ 281.0. result button in x = 562, meaning outside screen.

set button2 x coordinate 0 , see if helps:

button2.frame= cgrectmake(0.0, 5.0, image2.size.width, image2.size.height); 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -