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 7719501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:25:56+00:00 2026-06-01T03:25:56+00:00

I try to refresh background image of an uibutton, this is the code for

  • 0

I try to refresh background image of an uibutton, this is the code for create button

- (void) disegnaAnteprime {

int x = 2;
int y = 2;
int i = 0;

scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 10*103);

for (i=0; i < arrayProgetti.count;i++) {

    NSNumber *indice = [NSNumber numberWithInt:i];

    elemento = [arrayProgetti objectAtIndex:i];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:[elemento objectForKey:@"Titolo"] forState:UIControlStateNormal];

    [button addTarget:self action:@selector(openPdf:) forControlEvents:UIControlEventTouchUpInside];
    [button setContentVerticalAlignment:UIControlContentVerticalAlignmentBottom];
    button.tag = i;

    NSURL *indirizzoImmagine = [NSURL URLWithString:[elemento objectForKey:@"IndirizzoIcona"]];

    NSLog(@"Indice i: %d",i);

    NSData *imageData = [cache cachedResponseDataForURL:indirizzoImmagine]; 

    if (imageData==nil) {
        [self loadURL:indirizzoImmagine idElementoBottone:indice tipoRichiesta:NO];
    }
    else {
        [button setImage:[UIImage imageWithData:imageData] forState:UIControlStateNormal];        
    }

    button.frame = CGRectMake(30, y, 190, 190);
    y = y + 192;

    [self.scrollView addSubview:button];
}

}

while this is the code that I use for refresh button image

- (void)requestFinished:(ASIHTTPRequest *)request
{
      int tag = [[request.userInfo objectForKey:@"TagBottone"] intValue];        
      NSLog(@"Tag: %d",tag);

      [(UIButton*)[self.scrollView viewWithTag:tag] setTitle:@"hello" forState:UIControlStateNormal];        

}

but I get this error

[UIScrollView setTitle:forState:]: unrecognized selector sent to instance 0x8179eb0
2012-03-28 23:54:40.477 iVision[2269:15b03] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIScrollView setTitle:forState:]: unrecognized selector sent to instance 0x8179eb0’
*
First throw call stack:
(0x1c5f052 0x37f3d0a 0x1c60ced 0x1bc5f00 0x1bc5ce2 0xd574 0x1c60e72 0x37d0b 0x1c60e72 0x12879ef 0x1c3397f 0x1b96b73 0x1b96454 0x1b95db4 0x1b95ccb 0x1df1879 0x1df193e 0x96fa9b 0x3560 0x2d85)

where is the mistake?
edit:for now I try only to change titletex.

thank you!

  • 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-01T03:25:57+00:00Added an answer on June 1, 2026 at 3:25 am

    This states that you are trying to use setTitle:forState: in a scrollView rather than a UIButton. Have you tried separating the code:

    UIButton * btn = (UIButton*)[self.scrollView viewWithTag:tag];
    [btn setTitle:@"hello" forState:UIControlStateNormal];
    

    You can also check if your casting is succeeding:

    if([[self.scrollView viewWithTag:tag] isKindOfClass:[UIButton class]])
    {
        UIButton * btn = (UIButton*)[self.scrollView viewWithTag:tag];
        [btn setTitle:@"hello" forState:UIControlStateNormal];
    }
    

    It all indicates that the result of viewWithTag is not a UIButton. UIScrollView has some subviews itself. I would start your tags with a value of 100 and then, just add 100 to the result of the request. This avoids conflicts with existing subviews.

    Hope it helps.

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

Sidebar

Related Questions

this is my code: <script language=javascript> function refresh() { try { xmlhttp = window.XMLHttpRequest
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
Try the following code public enum Color { Blue=1, Red=2, Green=3 } public List<Color>
try it out: volatile float bob = -344.0f; unsigned int fred = (unsigned int)bob;
Try running this in a .VBS file MsgBox(545.14-544.94) You get a neat little answer
In my application, I am sending periodic cron and background task requests to refresh
when I try to use the following code in the codebehind file, it runs
Hi I try solve this situation. I have WPF app with MVVM design. I
public void RefreshEntities(object sender) { for (; ; ) { try { //refreshing entities
I have a thread with this run method: public void run(){ MAPTable t1 =

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.