ios - Cleanest way to present UIKeyCommands from custom UIControl -
i'm in process of writing custom uicontrol , need able present uikeycommands it. now, way have implemented exposing bool called shouldshowkeycommands.
when true, show corresponding commands:
- (void)moverowdown:(id)sender { [self.control setselectedatindex:[self.control selectedindex]+1]; } - (void)moverowup:(id)sender { [self.control setselectedatindex:[self.control selectedindex]-1]; } - (void)selectaction:(id)sender { [self.control performselectedindex]; } - (nsarray *)keycommands { if (self.control.shouldshowkeycommands) { nsarray *commands = @[ [uikeycommand keycommandwithinput:uikeyinputdownarrow modifierflags:uikeymodifiercommand action:@selector(moverowdown:) discoverabilitytitle:@"go down 1 button"], [uikeycommand keycommandwithinput:uikeyinputuparrow modifierflags:uikeymodifiercommand action:@selector(moverowup:) discoverabilitytitle:@"go 1 button"], [uikeycommand keycommandwithinput:@"\r" modifierflags:uikeymodifiercommand action:@selector(selectaction:) discoverabilitytitle:@"select action"] ]; return commands; } return @[]; } this works charm, doesn't feel clean. 1 thing considered after doing research making uicontrol uiviewcontroller, because allow me show them control. there other options handling this?
wiki
Comments
Post a Comment