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

  • Home
  • SEARCH
  • 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 1089635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:15:09+00:00 2026-05-16T23:15:09+00:00

I put a DragView (subclass of UIView) on a UITableViewCell with tag (row+20000) –

  • 0

I put a DragView (subclass of UIView) on a UITableViewCell with tag (row+20000)

- (UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{   

   NSInteger row=[indexPath row];
   NSInteger section=[indexPath section];
   static NSString *SimpleTableIdentifier1 = @"CellTableIdentifier";
   UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier1 ];
   if  (cell == nil) {
      cell=[[[UITableViewCell alloc] initWithFrame:CGRectZero 
      CGRect dragRect =CGRectMake(12.0f,6.0f,24.0f,24.0f);
      DragView *dragger =[[DragView alloc]  initWithFrame:dragRect];
      [dragger setTag: row+20000 ];

   }
   DragView *newDragger=(DragView*)[cell viewWithTag: row+20000 ];//error

   //......
   return cell;
}

But when I try to use the codes (line marks with ‘error’) to access the DragView, debugger shows that newDragger returns 0x0 which means no object.

I do not know where is wrong. I just guess there may be the reason of the amount limitation of maximium tag )

Welcome any comment.

Thanks

interdev

  • 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-05-16T23:15:10+00:00Added an answer on May 16, 2026 at 11:15 pm

    tag property has NSInteger type and can have any value NSInteger can hold, so 20000 should not cause problems.

    Code you posted definitely lacks some details – do you actually put dragger into your cell? Note also that it is recommended not to add subviews to UITableViewCell directly – you must add them to cell’s contentView instead:

    [cell.contentView addSubView: dragger];
    

    and access it later:

    DragView *newDragger=(DragView*)[cell.contentView viewWithTag: row+20000 ];
    

    Also note that your code will not work when table reuses the cells, that is when cell is used for a row different from the row it was initially created for and you will try to access subview with wrong tag anyway.

    P.S. Also see this question Detecting which UIButton was pressed in a UITableView. It deals with buttons but may be it will be helpful for your custom view as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

put the aspxgridview into aspxpopup control. when peform filter on the aspxgridview the row
I put UIScrollView on View. UIScrollView includes a UIView Customed. When I click a
Put differently: Is there a good reason to choose a loosely-typed collection over a
Put it another way: what code have you written that cannot fail. I'm interested
Put them all in one separate folder structure or along with classes which implements
Put simply: it causes a massive memory leak within an hour if I work
Put together an extremely simple Knockout.js exmaple to learn how it works. I immediately
Put simply, I want to select all data in two columns from each of
Put value as a field makes sense only if this one represents some object's
Put on your c++ ninja voodoo gloves. We purchased a 3rd party library to

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.