Amazon.com Widgets Global Variable (Data Sharing Troubleshoot)
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 16, 2014, 02:51:46 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ iOS Programming
| |-+ General Questions
| | |-+ Global Variable (Data Sharing Troubleshoot)
Pages: [1] Go Down
Print
Author Topic: Global Variable (Data Sharing Troubleshoot) (Read 594 times)
CnooB
Newbie
*
Posts: 12


Email




on: December 06, 2011, 04:58:47 PM

i have a global variable "prodTableArray" which is a barcode string that converts itself into an array so it can show the product number in the tableview. as sort of a shopping cart list.


but it pulls the barcode from the first view controller and it doesn't automatically show up in my tableview unless i rotate it, i also have a similar problem with with a UIImageView on another view controller except that i added a button to retrieve the image.

but i want to get rid of the button and do it automatically, is this possible?


heres my table code, how can it automatically update after each barcode scan, i know view willappear works but than the user is going to have to click on another view controller and click back to load the image.


Code: (Objective-C)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    ImageStrings* theDataObject = [self theImageClass];
    // Return the number of rows in the section.
    return [theDataObject.prodTableArray count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     ImageStrings* theDataObject = [self theImageClass];
    static NSString *CellIdentifier = @"Cell";
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

   
    cell.textLabel.text = [theDataObject.prodTableArray objectAtIndex:[indexPath row]];
   

   
    return cell;
}


Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #1 on: December 06, 2011, 05:28:09 PM

If I understand your question, you can use the UITableView's reloadData method to refresh the table if any of the row's contents change.

Cheers,

Steve
Logged
CnooB
Newbie
*
Posts: 12


Email




Reply #2 on: December 06, 2011, 06:10:06 PM

If I understand your question, you can use the UITableView's reloadData method to refresh the table if any of the row's contents change.

Cheers,

Steve


thank you I'm reading the class reference right now,


can the same be done for an image in UIImageView? i didn't see a reload function under the class reference
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #3 on: December 06, 2011, 10:05:41 PM

If you just assign the image property in the UIImageView to a different image it will cause the new image to be displayed.

Cheers,

Steve
Logged
CnooB
Newbie
*
Posts: 12


Email




Reply #4 on: December 07, 2011, 12:04:56 PM

If you just assign the image property in the UIImageView to a different image it will cause the new image to be displayed.

Cheers,

Steve


tyvm steve
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.