What's the best way to create a UITableViewCell
with an "info symbol" in the accessoryView/disclosure area? Like the iTunes Connect app
, that is when you login there is teh Account Name
cell, which has an "info" button you can click on. It basically has the text Account Name
on the left, then a text field for entry of the account name, and on the right the info icon you can click on.
Aspects of the question:
- 开发者_运维知识库which UITableViewCell
style is it using?
- is there a way to set the info
button as a disclosure type? or is it a custom cell where you have to put your own image there
- then depending on the answer to the above item, how would you trap the info button button push to trigger some help text to be displayed as a modal dialog
Background - I wanted to use this as a means to allow users to get context based help on each item.
try this set the frame according to where u want
UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];
button.frame = CGRectMake(3,8,30, 30);
[button addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];
I think what you want is You can just set a detail accessory view:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureIndicator;
This gives a little arrow > on the right. When the user taps a cell, the tableView delegate gets a didSelectRowAtIndexPath:
message. With a disclosure indicator, you generally respond by pushing a new viewController containing the desired information.
[self.navigationController pushViewController:self.itemHelpVC animated:YES];
From iOS 8 the UITableViewCellAccessoryDetailButton has the form of an info button, so you just need this:
cell.accessoryType = UITableViewCellAccessoryDetailButton;
Result:
精彩评论