Wednesday, 15 February 2012

ios - Custom UITableViewCell accessoryView button invisible on REAL device -



ios - Custom UITableViewCell accessoryView button invisible on REAL device -

in uitableview want add together custom accessoryview button rows in table; code, added in uitableviewcell cellforrowatindexpath method:

uiimage *image = [uiimage imagenamed:@"icon.png"]; uibutton *button = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 28, 28)]; // tested initwithframe:cgrectmake(0, 0, image.size.width, image.size.heigth) [uibutton buttonwithtype:uibuttontypecustom]; [button setbackgroundimage:image forstate:uicontrolstatenormal]; button.backgroundcolor = [uicolor clearcolor]; cell.accessoryview = button; [button addtarget:self action:@selector(accessorybuttontapped:event:) forcontrolevents:uicontroleventtouchupinside];

this works on ios simulator (ios 5.1 , ios 6.1), can see custom uibutton icon.png image on right of each row of table , can phone call accessorybuttontapped event tapping on custom image. if test app on real device (iphone 4 ios 5.1 or ipad 3rd ios 6.1) cannot see custom button, invisible, in fact tapping on right of each rows still calls accessorybuttontapped event. have deleted , re-installed app too, can do?

if method getting called, means button there. problem image. while running on device, check if image nil or not, , whether image has been added build target.

ios uitableview uibutton

No comments:

Post a Comment