ios - Navigation Bar custom button -


backbutton =  [uibutton buttonwithtype:uibuttontypecustom];  [backbutton addtarget:self action:@selector(gotoamphorasviewcontroller) forcontrolevents:uicontroleventtouchupinside];  [backbutton setframe:cgrectmake(0.0f,0.0f, 44,44)]; 

the problem facing though button dimensions are44*44, wherever tap anywhere around it, the button action fired.

please try bellow code : working properly

- (void)viewdidload {     [super viewdidload]; uiimage *buttonimage = [uiimage imagenamed:@"back.png"];      uibutton *button = [uibutton buttonwithtype:uibuttontypecustom];      [button setimage:buttonimage forstate:uicontrolstatenormal];       button.frame = cgrectmake(0, 0, buttonimage.size.width, buttonimage.size.height);       [button addtarget:self action:@selector(back) forcontrolevents:uicontroleventtouchupinside];      uibarbuttonitem *custombaritem = [[uibarbuttonitem alloc] initwithcustomview:button];      self.navigationitem.leftbarbuttonitem = custombaritem;     [custombaritem release];    }  -(void)back {  [self.navigationcontroller popviewcontrolleranimated:yes]; } 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -