Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:57:52+00:00 2026-06-15T23:57:52+00:00

I have a UITextView in UIViewController . In that UITextView , need to insert

  • 0

I have a UITextView in UIViewController. In that UITextView, need to insert Multiple CheckBoxes for notes.

How to create multiple checkBoxes??

I have created Multiple CheckBoxes for `UIButton` Click, But When I Select or DeSelect operation, all ChecKBoxes Value changes.

How can I create multiple checkBoxes and create method for those CheckBoxes dynamically?

Is it possible?

Here is my code:

-(void)Check
{
    CGPoint origin = note.frame.origin;
    NSString* head = [note.text substringToIndex:note.selectedRange.location];
    CGSize initialSize = [head sizeWithFont:note.font constrainedToSize:note.contentSize];
    NSUInteger startOfLine = [head length];

    NSString* tail = [head substringFromIndex:startOfLine];
    CGSize lineSize = [tail sizeWithFont:note.font forWidth:note.contentSize.width lineBreakMode:UILineBreakModeWordWrap];
    CGPoint cursor = origin;
    cursor.x += lineSize.width+15;
    cursor.y += initialSize.height - lineSize.height-130;

checkbox = [[UIButton alloc] initWithFrame:CGRectMake(cursor.x,cursor.y,15,15)];
    [checkbox setBackgroundImage:[UIImage imageNamed:@"unchk.png"]forState:UIControlStateNormal];
    [checkbox setBackgroundImage:[UIImage imageNamed:@"chk.png"]forState:UIControlStateSelected];
    [checkbox setBackgroundImage:[UIImage imageNamed:@"chk.png"]forState:UIControlStateHighlighted];
    checkbox.adjustsImageWhenHighlighted=YES;
    [checkbox addTarget:self action:@selector(ChkUnChk) forControlEvents:UIControlEventTouchUpInside];
    [note addSubview:checkbox];
}

-(void)ChkUnChk
{
    if(checkUnCheck==NO)
    {
        [checkbox setBackgroundImage:[UIImage imageNamed:@"chk.png"]forState:UIControlStateNormal];
        checkUnCheck=YES;
    }
    else if(checkUnCheck==YES)
    {
        [checkbox setBackgroundImage:[UIImage imageNamed:@"unchk.png"]forState:UIControlStateNormal];
        checkUnCheck=NO;
    }
}

-(void)checkboxSelected:(id)sender
{
    checkBoxSelected = !checkBoxSelected;
    [checkbox setSelected:checkBoxSelected];
}

here note –> UITextView,checkbox –> UIButton

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:57:52+00:00Added an answer on June 15, 2026 at 11:57 pm

    Take a NSMutableArray..

    in .h file

    NSMutableArray *selectedBtnarr;
    

    in .m file

     - (void)viewDidLoad
       {
             selectedBtnarr=[NSMutableArray alloc]init];
       }
    

    Then, you have to set tag property of UIButton. Each Button has different tag.

    -(void)ChkUnChk:(id)sender
    {
    
        UIButton *btn=(UIButton *)sender;
        NSString *Str=[NSString stringWithFormat:@"%d",btn.tag];
        BOOL flag=   [selectedBtnarr containsObject:Str];
    
        if (flag==YES)
        {
            [btn setBackgroundImage:[UIImage imageNamed:@"unchk.png"]    forState:UIControlStateNormal];
            [selectedBtnarr removeObject:Str];
        }
        else
        {
            [selectedBtnarr addObject:Str];
            [btn setBackgroundImage:[UIImage imageNamed:@"chk.png"] forState:UIControlStateNormal];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIViewController. In this controller I programmatically create a UITextView and set
I have a UITextView that works well, till it's content is larger than it's
I have a UiTextView inside a custom UITableViewCell. The keyboard appears when i select
I have a UITextView that has a lot of content. I have a button
I have a UITextview in my Screen,I created textview in drag and drop on
I have a UIViewController that presents another UIViewController with a picker and returns four
I'm trying to create a UITextView in my Main UIViewController when a UIControlEventTouchUpInside happens
I have a UITextView that is supposed to have one line of text. The
I have a UIViewController that implements UITextViewDelegate and is connected as the delegate to
I have the following code: @interface NeighborProfileViewController : UIViewController { UIImageView * profPic; UITextView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.