Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put checkmark in the left side of UITableViewCell

I want to make something similar to the WiFi settings page: when you tap the table cell, put a checkbox in the left side of the cell, and have a disclosure button accessory view on the right to show more details.

My question: is there a way to put the checkmark in the left side of a UITableViewCell without building a custom UITableViewCell ?

like image 706
Nicu Surdu Avatar asked Jan 06 '12 09:01

Nicu Surdu


3 Answers

The answer is YES! You don't have to create a custom cell for that or add image views. To simulate checkboxes you only have to prepend a unicode symbol for a checkbox state to the cell text.

The unicode symbols I'm using for checkboxes are \u2705 for checked and \u2B1C for unchecked (nearly the same as \U0001F533 on iOS 5). iOS renders several unicode symbols as icons.

Here are some other symbols:

enter image description here

@"\u2611", @"\u2B1C", @"\u2705", @"\u26AB", @"\u26AA", @"\u2714", @"\U0001F44D", @"\U0001F44E"

Imitating the Wi-Fi settings page (with UITableViewCellStyleValue1):

enter image description here

cell.textLabel.text = @"\u2001 Wi-Fi 1";
cell.detailTextLabel.text = @"\U0001F512 \u268A";

cell.textLabel.text = @"\u2001 Wi-Fi 2";
cell.detailTextLabel.text = @"\U0001F512 \u268C";

cell.textLabel.text = @"\u2713 Wi-Fi 3";
cell.detailTextLabel.text = @"\U0001F513 \u2630";
like image 187
Eddie G. Avatar answered Nov 07 '22 22:11

Eddie G.


Of course you can do that :) For example use UITableViewCellStyle

UITableViewCellStyleDefault,
// Simple cell with text label and optional image view
//(behavior of UITableViewCell in iPhoneOS 2.x)

...and put a custom "checkmark" image in that "optional image view".

like image 35
JOM Avatar answered Nov 07 '22 22:11

JOM


In Swift you can press Command + Ctrl + Spacebar to show emoticons and special characters or you can copy this ✓ ✔️

like image 1
Azam Avatar answered Nov 07 '22 23:11

Azam