objective c - Adding a segue from a programmatically defined button -
my current application uses storyboard interface builder, , have reached limit on adding bar button items navigation bar. have right bar button item , left bar button item, need add third button segue new view controller. since dragging new bar button item wouldn't work in storyboard, created button programmatically within view controller , used arraybyaddingobject incorporate current right bar item , new right bar item. keep ui within storyboard if @ possible.
my first question here is there way view button created programmatically within storyboard? if not, there simple solution adding more 2 bar button items within storyboard? below current code new bar button item.
one last thing: if choose go programmatic approach, how segue view controller created in storyboard in action method.
button initializedself.categorybuttonitem = [[uibarbuttonitem alloc] initwithtitle:nslocalizedstring(@"cat", @"categories button") style:uibarbuttonitemstyledone target:self action:@selector(categorybuttondidpress:)]; self.navigationitem.rightbarbuttonitems = [self.navigationitem.rightbarbuttonitems arraybyaddingobject:self.categorybuttonitem];
action method -(void) categorybuttondidpress:(uibarbuttonitem *)sender { }
i don't think can see button in storyboard. ok add programmatically though. create segue in storyboard without attaching particular button (just drag 1 view controller another, , create segue). give segue identified (in attributes inspector), example "categorysegue". this:
-(void) categorybuttondidpress:(uibarbuttonitem *)sender { [self performseguewithidentifier:@"categorysegue" sender:nil]; }
Comments
Post a Comment