i have tricky problem , after long searching (google, stackoverflow, ...) didn't solution works me.
let me introduce in current choosen architecture:
i have a appdelegate, has uiview contains uinavigationcontroller , application didfinishlaunchingwithoptions: contains:
uiview *myview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 200, 400)]; uiviewcontroller *mycontroller = [[uiviewcontroller alloc] init]; mycontroller.view = myview; fscscrumrootview * myrootview = [[fscscrumrootview alloc] initwithnibname:@"fscscrumrootview" bundle:[nsbundle mainbundle]]; [mycontroller.view addsubview:myrootview.navigation.view]; [self.window addsubview:mycontroller.view]; [self.window makekeyandvisible]; return yes; }
in fscscrumrootview (inherits uiviewcontroller) init view this:
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization self.navigation = [[[uinavigationcontroller alloc] init] autorelease]; self.scrumprojectslist = [[[fscscrumprojectlistview alloc] init] initwithnibname:@"fscscrumprojectlistview" bundle:nil]; [navigation pushviewcontroller:scrumprojectslist animated:yes]; [navigation view]; } return self; }
in fscscrumprojectlistview (it inherited uitableviewcontroller) have implemented viewdidload following:
- (void)viewdidload { [super viewdidload]; //set title self.navigationitem.title = @"scrum projects"; uibarbuttonitem *myrefreshbutton = [[[uibarbuttonitem alloc] initwithtitle:@"refresh" style:uibarbuttonsystemitemrefresh target:self action:@selector(refreshlist)] autorelease]; self.navigationitem.leftbarbuttonitem = myrefreshbutton; uibarbuttonitem *mylogoutbutton = [[uibarbuttonitem alloc] initwithtitle:@"logout" style:uibarbuttonsystemitemcancel target:self action:@selector(logout)]; self.navigationitem.rightbarbuttonitem = mylogoutbutton; //initialize toolbar toolbar = [[uitoolbar alloc] init]; toolbar.barstyle = uibarstyledefault; //set toolbar fit width of app. [toolbar sizetofit]; //caclulate height of toolbar cgfloat toolbarheight = [toolbar frame].size.height; //get bounds of parent view cgrect rootviewbounds = self.parentviewcontroller.view.bounds; //get height of parent view. cgfloat rootviewheight = cgrectgetheight(rootviewbounds); //get width of parent view, cgfloat rootviewwidth = cgrectgetwidth(rootviewbounds); //create rectangle toolbar cgrect rectarea = cgrectmake(0, rootviewheight - toolbarheight, rootviewwidth, toolbarheight); //reposition , resize receiver [toolbar setframe:rectarea]; //create button uibarbuttonitem *infobutton = [[uibarbuttonitem alloc] initwithtitle:@"info" style:uibarbuttonitemstylebordered target:self action:@selector(info_clicked:)]; [toolbar setitems:[nsarray arraywithobjects:infobutton,nil]]; //add toolbar subview navigation controller. [self.navigationcontroller.view addsubview:toolbar]; //reload table view [self.tableview reloaddata]; }
this results in following screen (as i'd have it): view ios mockup of current result
the problem: problem is, can click on refresh button. other 2 buttons (info , logout) cannot clicked. , don't understand why? doing wrong here?
your kindly appreceated!
try autoreleasing second 2 buttons first 1 (the refresh).
uibarbuttonitem *mylogoutbutton = [[[uibarbuttonitem alloc] initwithtitle:@"logout" style:uibarbuttonsystemitemcancel target:self action:@selector(logout)]autorelease]; uibarbuttonitem *infobutton = [[[uibarbuttonitem alloc] initwithtitle:@"info" style:uibarbuttonitemstylebordered target:self action:@selector(info_clicked:)]autorelease];
Comments
Post a Comment