Search Results

Search found 655 results on 27 pages for 'uitableviewcell'.

Page 19/27 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • All UITableCells rendered at once... why?

    - by Greg
    I'm extremely confused by the proper behavior of UITableView cell rendering. Here's the situation: I have a list of 250 items that are loading into a table view, each with an image. To optimize the image download, I followed along with Apple's LazyTableImages sample code... pretty much following it exactly. Really good system... for reference, here's the cell renderer within the Apple sample code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // customize the appearance of table view cells // static NSString *CellIdentifier = @"LazyTableCell"; static NSString *PlaceholderCellIdentifier = @"PlaceholderCell"; // add a placeholder cell while waiting on table data int nodeCount = [self.entries count]; if (nodeCount == 0 && indexPath.row == 0) { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease]; cell.detailTextLabel.textAlignment = UITextAlignmentCenter; cell.selectionStyle = UITableViewCellSelectionStyleNone; } cell.detailTextLabel.text = @"Loading…"; return cell; } UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } // Leave cells empty if there's no data yet if (nodeCount > 0) { // Set up the cell... AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row]; cell.textLabel.text = appRecord.appName; cell.detailTextLabel.text = appRecord.artist; // Only load cached images; defer new downloads until scrolling ends if (!appRecord.appIcon) { if (self.tableView.dragging == NO && self.tableView.decelerating == NO) { [self startIconDownload:appRecord forIndexPath:indexPath]; } // if a download is deferred or in progress, return a placeholder image cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"]; } else { cell.imageView.image = appRecord.appIcon; } } return cell; } So – my implementation of Apple's LazyTableImages system has one crucial flaw: it starts all downloads for all images immediately. Now, if I remove this line: //[self startIconDownload:appRecord forIndexPath:indexPath]; Then the system behaves exactly like you would expect: new images load as their placeholders scroll into view. However, the initial view cells do not automatically load their images without that prompt in the cell renderer. So, I have a problem: with the prompt in the cell renderer, all images load at once. Without the prompt, the initial view doesn't load. Now, this works fine in Apple sample code, which got me wondering what was going on with mine. It's almost like it was building all cells up front rather than just the 8 or so that would appear within the display. So, I got looking into it, and this is indeed the case... my table is building 250 unique cells! I didn't think the UITableView worked like this, I guess I thought it only built as many items as were needed to populate the table. Is this the case, or is it correct that it would build all 250 cells up front? Also – related question: I've tried to compare my implementation against the Apple LazyTableImages sample, but have discovered that NSLog appears to be disabled within the Apple sample code (which makes direct behavior comparisons extremely difficult). Is that just a simple publish setting somewhere, or has Apple somehow locked down their samples so that you can't log output at runtime? Thanks!

    Read the article

  • iPhone: didSelectRowAtIndexPath not invoked

    - by soletan
    Hi, I know this issue being mentioned before, but resolutions there didn't apply. I'm having a UINavigationController with an embedded UITableViewController set up using IB. In IB the UITableView's delegate and dataSource are both set to my derivation of UITableViewController. This class has been added using XCode's templates for UITableViewController classes. There is no custom UITableViewCell and the table view is using default plain style with single title, only. Well, in simulator the list is rendered properly, with two elements provided by dataSource, so dataSource is linked properly. If I remove the outlet link for dataSource in IB, an empty table is rendered instead. As soon as I tap on one of these two items, it is flashing blue and the GDB encounters interruption in __forwarding__ in scope of a UITableView::_selectRowAtIndexPath. It's not reaching breakpoint set in my non-empty method didSelectRowIndexPath. I checked the arguments and method's name to exclude typos resulting in different selector. I recently didn't succeed in whether delegate is set properly, but as it is set equivalently to dataSource which is getting two elements from the same class, I expect it to be set properly. So, what's wrong? I'm running iPhone/iPad SDK 3.1.2 ... but tried with iPhone SDK 3.1 in simulator as well. EDIT: This is the code of my UITableViewController derivation: #import "LocalBrowserListController.h" #import "InstrumentDescriptor.h" @implementation LocalBrowserListController - (void)viewDidLoad { [super viewDidLoad]; [self listLocalInstruments]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { [super viewDidUnload]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [entries count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; if ( ( [entries count] > 0 ) && ( [indexPath length] > 0 ) ) cell.textLabel.text = [[[entries objectAtIndex:[indexPath indexAtPosition:[indexPath length] - 1]] label] retain]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ( ( [entries count] > 0 ) && ( [indexPath length] > 0 ) ) { ... } } - (void)dealloc { [super dealloc]; } - (void) listLocalInstruments { NSMutableArray *result = [NSMutableArray arrayWithCapacity:10]; [result addObject:[InstrumentDescriptor descriptorOn:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"idl"] withLabel:@"Default 1"]]; [result addObject:[InstrumentDescriptor descriptorOn:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"xml"] withLabel:@"Default 2"]]; [entries release]; entries = [[NSArray alloc] initWithArray:result]; } @end

    Read the article

  • iOS TableView crash loading different data

    - by jollyr0ger
    Hi to all! I'm developing a simple iOS app where there is a table view with some categories (CategoryViewController). When clicking one of this category the view will be passed to a RecipesListController with another table view with recipes. This recipes are loaded from different plist based on the category clicked. The first time I click on a category, the recipes list is loaded and shown correctely. If i back to the category list and click any of the category (also the same again) the app crash. And I don't know how. The viewWillAppear is ececuted correctely but after crash. Can you help me? If you need the entire project I can zip it for you. Ok? Here is the code of the CategoryViewController.h #import <Foundation/Foundation.h> #import "RecipeRowViewController.h" @class RecipesListController; @interface CategoryViewController : UITableViewController { NSArray *recipeCategories; RecipesListController *childController; } @property (nonatomic, retain) NSArray *recipeCategories; @end The CategoryViewControoler.m #import "CategoryViewCotroller.h" #import "NavAppDelegate.h" #import "RecipesListController.h" @implementation CategoryViewController @synthesize recipeCategories; - (void)viewDidLoad { // Create the categories NSArray *array = [[NSArray alloc] initWithObjects:@"Antipasti", @"Focacce", @"Primi", @"Secondi", @"Contorni", @"Dolci", nil]; self.recipeCategories = array; [array release]; // Set background image UIImageView *bgImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sfondo_app.png"]]; [self.tableView setBackgroundView:bgImg]; [bgImg release]; [self.tableView reloadData]; [super viewDidLoad]; } - (void)viewDidUnload { self.recipeCategories = nil; // [childController release]; [super viewDidUnload]; } - (void)dealloc { [recipeCategories release]; // [childController release]; [super dealloc]; } #pragma mark - #pragma mark Table data source methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [recipeCategories count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellId = @"RecipesCategoriesCellId"; // Try to reuse a cell or create a new one UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellId]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellId] autorelease]; } // Get the right value and assign to the cell NSUInteger row = [indexPath row]; NSString *rowString = [recipeCategories objectAtIndex:row]; cell.textLabel.text = rowString; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; [rowString release]; return cell; } #pragma mark - #pragma mark Table view delegate methods - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (childController == nil) { childController = [[RecipesListController alloc] initWithStyle:UITableViewStyleGrouped]; } childController.title = @"Ricette"; childController.category = [indexPath row]; [self.navigationController pushViewController:childController animated:YES]; } @end The RecipesListController.h #import <Foundation/Foundation.h> #import "RecipeRowViewController.h" #define kRecipeArrayLink 0 #define kRecipeArrayDifficulty 1 #define kRecipeArrayFoodType 2 #define kRecipeAntipasti 0 #define kRecipeFocacce 1 #define kRecipePrimi 2 #define kRecipeSecondi 3 #define kRecipeContorni 4 #define kRecipeDolci 5 @class DisclosureDetailController; @interface RecipesListController : UITableViewController { NSInteger category; NSDictionary *recipesArray; NSArray *recipesNames; NSArray *recipesLinks; DisclosureDetailController *childController; } @property (nonatomic) NSInteger category; @property (nonatomic, retain) NSDictionary *recipesArray; @property (nonatomic, retain) NSArray *recipesNames; @property (nonatomic, retain) NSArray *recipesLinks; @end The RecipesListcontroller.m #import "RecipesListController.h" #import "NavAppDelegate.h" #import "DisclosureDetailController.h" @implementation RecipesListController @synthesize category, recipesArray, recipesNames, recipesLinks; - (void)viewDidLoad { // Set background image UIImageView *bgImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sfondo_app.png"]]; [self.tableView setBackgroundView:bgImg]; [bgImg release]; [self.tableView reloadData]; [super viewDidLoad]; } - (void)viewWillAppear:(BOOL)animated { if (self.recipesArray != nil) { // Release the arrays [self.recipesArray release]; [self.recipesNames release]; } // Load the dictionary NSString *path = nil; // Load a different dictionary, based on the category if (self.category == kRecipeAntipasti) { path = [[NSBundle mainBundle] pathForResource:@"recipes_antipasti" ofType:@"plist"]; } else if (self.category == kRecipeFocacce) { path = [[NSBundle mainBundle] pathForResource:@"recipes_focacce" ofType:@"plist"]; } else if (self.category == kRecipePrimi) { path = [[NSBundle mainBundle] pathForResource:@"recipes_primi" ofType:@"plist"]; } else if (self.category == kRecipeSecondi) { path = [[NSBundle mainBundle] pathForResource:@"recipes_secondi" ofType:@"plist"]; } else if (self.category == kRecipeContorni) { path = [[NSBundle mainBundle] pathForResource:@"recipes_contorni" ofType:@"plist"]; } else if (self.category == kRecipeDolci) { path = [[NSBundle mainBundle] pathForResource:@"recipes_dolci" ofType:@"plist"]; } NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path]; self.recipesArray = dict; [dict release]; // Save recipes names NSArray *array = [[recipesArray allKeys] sortedArrayUsingSelector: @selector(compare:)]; self.recipesNames = array; [self.tableView reloadData]; [super viewWillAppear:animated]; } - (void)viewDidUnload { self.recipesArray = nil; self.recipesNames = nil; self.recipesLinks = nil; // [childController release]; [super viewDidUnload]; } - (void)dealloc { [recipesArray release]; [recipesNames release]; [recipesLinks release]; // [childController release]; [super dealloc]; } #pragma mark - #pragma mark Table data source methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [recipesNames count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *RecipesListCellId = @"RecipesListCellId"; // Try to reuse a cell or create a new one UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RecipesListCellId]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RecipesListCellId] autorelease]; } // Get the right value and assign to the cell NSUInteger row = [indexPath row]; NSString *rowString = [recipesNames objectAtIndex:row]; cell.textLabel.text = rowString; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; [rowString release]; return cell; } #pragma mark - #pragma mark Table view delegate methods - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (childController == nil) { childController = [[DisclosureDetailController alloc] initWithNibName:@"DisclosureDetail" bundle:nil]; } childController.title = @"Dettagli"; NSUInteger row = [indexPath row]; childController.recipeName = [recipesNames objectAtIndex:row]; NSArray *recipeRawArray = [recipesArray objectForKey:childController.recipeName]; childController.recipeLink = [recipeRawArray objectAtIndex:kRecipeArrayLink]; childController.recipeDifficulty = [recipeRawArray objectAtIndex:kRecipeArrayDifficulty]; [self.navigationController pushViewController:childController animated:YES]; } @end This is the crash log Program received signal: “EXC_BAD_ACCESS”. (gdb) bt #0 0x00f0da63 in objc_msgSend () #1 0x04b27ca0 in ?? () #2 0x00002665 in -[RecipesListController viewWillAppear:] (self=0x4b38a00, _cmd=0x6d81a2, animated=1 '\001') at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/RecipesListController.m:67 #3 0x00370c9a in -[UINavigationController _startTransition:fromViewController:toViewController:] () #4 0x0036b606 in -[UINavigationController _startDeferredTransitionIfNeeded] () #5 0x0037283e in -[UINavigationController pushViewController:transition:forceImmediate:] () #6 0x04f49549 in -[UINavigationControllerAccessibility(SafeCategory) pushViewController:transition:forceImmediate:] () #7 0x0036b4a0 in -[UINavigationController pushViewController:animated:] () #8 0x00003919 in -[CategoryViewController tableView:didSelectRowAtIndexPath:] (self=0x4b27ca0, _cmd=0x6d19e3, tableView=0x500c200, indexPath=0x4b2d650) at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/CategoryViewCotroller.m:104 #9 0x0032a794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] () #10 0x00320d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] () #11 0x000337f6 in __NSFireDelayedPerform () #12 0x00d8cfe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ () #13 0x00d8e594 in __CFRunLoopDoTimer () #14 0x00ceacc9 in __CFRunLoopRun () #15 0x00cea240 in CFRunLoopRunSpecific () #16 0x00cea161 in CFRunLoopRunInMode () #17 0x016e0268 in GSEventRunModal () #18 0x016e032d in GSEventRun () #19 0x002c342e in UIApplicationMain () #20 0x00001c08 in main (argc=1, argv=0xbfffef58) at /Users/claudiocanino/Documents/iOS/CottoMangiato/main.m:15 Another bt log: (gdb) bt #0 0x00cd76a1 in __CFBasicHashDeallocate () #1 0x00cc2bcb in _CFRelease () #2 0x00002dd6 in -[RecipesListController setRecipesArray:] (self=0x6834d50, _cmd=0x4293, _value=0x4e3bc70) at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/RecipesListController.m:16 #3 0x00002665 in -[RecipesListController viewWillAppear:] (self=0x6834d50, _cmd=0x6d81a2, animated=1 '\001') at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/RecipesListController.m:67 #4 0x00370c9a in -[UINavigationController _startTransition:fromViewController:toViewController:] () #5 0x0036b606 in -[UINavigationController _startDeferredTransitionIfNeeded] () #6 0x0037283e in -[UINavigationController pushViewController:transition:forceImmediate:] () #7 0x091ac549 in -[UINavigationControllerAccessibility(SafeCategory) pushViewController:transition:forceImmediate:] () #8 0x0036b4a0 in -[UINavigationController pushViewController:animated:] () #9 0x00003919 in -[CategoryViewController tableView:didSelectRowAtIndexPath:] (self=0x4b12970, _cmd=0x6d19e3, tableView=0x5014400, indexPath=0x4b2bd00) at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/CategoryViewCotroller.m:104 #10 0x0032a794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] () #11 0x00320d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] () #12 0x000337f6 in __NSFireDelayedPerform () #13 0x00d8cfe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ () #14 0x00d8e594 in __CFRunLoopDoTimer () #15 0x00ceacc9 in __CFRunLoopRun () #16 0x00cea240 in CFRunLoopRunSpecific () #17 0x00cea161 in CFRunLoopRunInMode () #18 0x016e0268 in GSEventRunModal () #19 0x016e032d in GSEventRun () #20 0x002c342e in UIApplicationMain () #21 0x00001c08 in main (argc=1, argv=0xbfffef58) at /Users/claudiocanino/Documents/iOS/CottoMangiato/main.m:15 Thanks

    Read the article

  • Can anybody help me in designing my UITableView into MVC Pattern ?

    - by user2877880
    I have written a ViewController in which i get data from the internet and display it in a UItableview using a json parser which uses object for key to identify its objects. What i would like your help in is to convert it into MVC pattern to make it less clumsy instead of including everything in the same controller class. Please try explaining it to me in terms of my code. THANKS IN ADVANCE. The code is as given below #import "ViewController.h" #import "AFNetworking.h" #import "ModelTableArray.h" @implementation ViewController @synthesize tableView = _tableView, activityIndicatorView = _activityIndicatorView, movies = _movies; - (void)viewDidLoad { [super viewDidLoad]; // Setting Up Table View self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain]; self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.tableView.hidden = YES; [self.view addSubview:self.tableView]; // Setting Up Activity Indicator View self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; self.activityIndicatorView.hidesWhenStopped = YES; self.activityIndicatorView.center = self.view.center; [self.view addSubview:self.activityIndicatorView]; [self.activityIndicatorView startAnimating]; // Initializing Data Source self.movies = [[NSArray alloc] init]; NSURL *url = [[NSURL alloc] initWithString:@"http://itunes.apple.com/search?term=rocky&country=us&entity=movie"]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; [self.tableView addSubview:refreshControl]; [refreshControl endRefreshing]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { self.movies = [JSON objectForKey:@"results"]; [self.activityIndicatorView stopAnimating]; [self.tableView setHidden:NO]; [self.tableView reloadData]; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo); }]; [operation start]; } - (void)refresh:(UIRefreshControl *)sender { NSURL *url = [[NSURL alloc] initWithString:@"http://itunes.apple.com/search?term=rambo&country=us&entity=movie"]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { self.movies = [JSON objectForKey:@"results"]; [self.activityIndicatorView stopAnimating]; [self.tableView setHidden:NO]; [self.tableView reloadData]; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo); }]; [operation start]; [sender endRefreshing]; } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } // Table View Data Source Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (self.movies && self.movies.count) { return self.movies.count; } else { return 0; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"Cell Identifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID]; } NSDictionary *movie = [self.movies objectAtIndex:indexPath.row]; cell.textLabel.text = [movie objectForKey:@"trackName"]; cell.detailTextLabel.text = [movie objectForKey:@"artistName"]; NSURL *url = [[NSURL alloc] initWithString:[movie objectForKey:@"artworkUrl100"]]; [cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder"]]; return cell; } @end

    Read the article

  • Creating Drill-Down Detail UITableView from JSON NSDictionary

    - by Michael Robinson
    I'm have a load of trouble finding out how to do this, I want to show this in a UITableDetailView (Drill-Down style) with each item in a different cell. All of the things I've read all show how to load a single image on the detail instead of showing as a UITableView. Does the dictionary have to have "children" in order to load correctly? Here is the code for the first view creating *dict from the JSON rowsArray. I guess what I'm looking for is what to put in the FollowingDetailViewController.m to see the rest of *dict contents, so when selecting a row, it loads the rest of the *dict. I have rowsArray coming back as follows: '{ loginName = Johnson; memberid = 39; name = Kris; age = ;}, etc,etc... Thanks, // SET UP TABLE & CELLS - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } NSDictionary *dict = [rowsArray objectAtIndex: indexPath.row]; cell.textLabel.text = [dict objectForKey:@"name"]; cell.detailTextLabel.text = [dict objectForKey:@"loginName"]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - (void)viewDidLoad { [super viewDidLoad]; //GET JSON FROM WEBSERVICES: NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"]; NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url]; NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rowsArray = [dict objectForKey:@"member"]; [rowsArray retain]; } [jsonreturn release]; } //GO TO DETAIL VIEW: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { FollowingDetailViewController *aFollowDetail = [[FollowingDetailViewController alloc] initWithNibName:@"FollowingDetailView" bundle:nil]; [self.navigationController pushViewController:aFollowDetail animated:YES]; }

    Read the article

  • UITableView not reloading data on [self.tableView reloadData]

    - by donnib
    I have following code : - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; static NSString *RowListCellIdentifier = @"RowListCellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RowListCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RowListCellIdentifier]autorelease]; } NSMutableString *rowString = [[NSMutableString alloc] init]; [rowString appendString:[[[rows objectAtIndex:row] firstNumber]stringValue]]; [rowString appendString:@" : "]; [rowString appendString:[[[rows objectAtIndex:row] secondNumber]stringValue]]; [rowString appendString:@" : "]; [[cell textLabel] setText:rowString]; [rowString release]; return cell; } - (void)viewWillAppear:(BOOL)animated { [self.tableView reloadData]; [super viewWillAppear:animated]; } My problem is that the textLabel does not get reloaded with new data. If i log the rowString i see the correct value so data is good but in the UI it's the old data. I can see the cellForRowAtIndexPath beeing called so i know the reloadDatacall goes thru. What am i doing wrong ?

    Read the article

  • UISearchDisplayController "shouldReloadTableForSearchString return NO" reloads table

    - by Jeena
    Why does my UISearchDisplayController show "No results" even if the shouldReloadTableForSearchString method returns NO? Shouldn't it just do nothing and stay black? How can I prevent it from doing so? #import "RootViewController.h" #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.searchDisplayController.searchResultsTableView) { return 0; } return 10; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. cell.textLabel.text = [NSString stringWithFormat:@"row %d", indexPath.row]; return cell; } #pragma mark SearchController stuff - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { return NO; } - (void)dealloc { [super dealloc]; } @end

    Read the article

  • Opening a View with a Table without a NavigationController

    - by Ken
    Hiya, I'm pretty new to developing with Cocoa Touch/XCode and I came across a problem. I'm making a sort of RSS reader for a newssite and I have 5 views of tables navigated with 5 tabs in a TabBarController. If someone selects a newsitem I want another view to open showing the complete newsitem. My problem is that it won't work. This is my code: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection(NSInteger)section{ return [[[self rssParser]rssItems]count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"rssItemCell"]; if(nil == cell){ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"rssItemCell"]autorelease]; } cell.textLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]title]; cell.detailTextLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]description]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [[self appDelegate] setCurrentlySelectedBlogItem:[[[self rssParser]rssItems]objectAtIndex:indexPath.row]]; [self.appDelegate loadNewsDetails]; } And it calls this method in my delegate: -(void)loadNewsDetails{ [[self rootController]pushViewController:detailController animated:YES]; } Please tell me what I'm doing wrong. BTW I do not want to use a NavigationController, just the tabbar I'm using. Thanks in advance, Ken

    Read the article

  • iphone sdk - UITableView - cannot assign a table to the table view

    - by kossibox
    hello, this is a part of my code. My application crashes when i try to load the view including the uitableview. i think there's a problem with the table i'm tryin to use but can't find it. help please gameTimingTable=[NSArray arrayWithObjects:@"2min + 10sec/coup",@"1min + 15sec/coup",@"5min",nil]; declared in .h as NSArray *gameTimingTable; this is the code i'm using to assign the table to the uitableview - (void)viewDidLoad { gameTimingTable=[NSArray arrayWithObjects:@"2min + 10sec/coup",@"1min + 15sec/coup",@"5min",nil]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // There is only one section. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of time zone names. return [gameTimingTable count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; // Try to retrieve from the table view a now-unused cell with the given identifier. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; // If no cell is available, create a new one using the given identifier. if (cell == nil) { // Use the default cell style. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } // Set up the cell. NSString *cadence = [gameTimingTable objectAtIndex:indexPath.row]; cell.textLabel.text = cadence; return cell; } /* To conform to Human Interface Guildelines, since selecting a row would have no effect (such as navigation), make sure that rows cannot be selected. */ - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { return nil; } thanks a lot

    Read the article

  • Grouped UITableView shows blank space when section is empty

    - by christo16
    Hello, I have a grouped UITableView where not all sections may be displayed at once, the table is driven by some data that not every record may have. My trouble is that the records that don't have certain sections show up as blank spaces in the table (see picture) There are no footers/headers. Anything I've missed? - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self getRowCount:section]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [NSString stringWithFormat:@"section: %d row: %d",indexPath.section,indexPath.row]; // Configure the cell... return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { float height = 0.0; if([self getRowCount:indexPath.section] != 0){ height = kDefaultRowHeight; } return height; }

    Read the article

  • initWithCoder and initWithNibName

    - by vodkhang
    I am trying to encode some data state in a UITableViewController. In the first time, I init the object with Nibname without any problem. However, when I initWithCoder, the UITableViewController still loads but when I clicked on a cell, the application crash and the debugger tells me about EXEC_BAD_ACCESS, something wrong with my memory, but I do not know Here is my code: - (id) init { if(self = [self initWithNibName:@"DateTableViewController" bundle:nil]) { self.dataArray = [[NSMutableArray alloc] initWithObjects:@"1", @"2", @"3", nil]; } return self; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... int index = indexPath.row; cell.textLabel.text = [self.dataArray objectAtIndex:index];; return cell; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return @"Test Archiver"; } - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; [coder encodeObject:self.dataArray]; } - (id)initWithCoder:(NSCoder *)coder { return [self init]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int index = indexPath.row; [self.dataArray addObject:[NSString stringWithFormat:@"Hello %d", index]]; [self.tableView reloadData]; }

    Read the article

  • how to set UISwitch pointer to access switch from one uiviewcontroller another uiviewcontroller

    - by Rkm
    System UIViewcontroller has button event.Tap on Button fire InfoTableviewController. InfoTableview has UISwitch . How to set NSMutableArray of UIswitch pointer for System UIViewcontroller to access switch . SystemUIviewcontroller button event - (IBAction) Info_Button_Clicked:(id) sender { // pushcontroller Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:info animated:YES]; [info release]; } Here for Info TableviewController // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if ([indexPath section] == 0) { static NSString *kDisplayCell_ID = @"DisplayCellID"; cell = [self.tableView dequeueReusableCellWithIdentifier: kDisplayCell_ID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: kDisplayCell_ID] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } else { // the cell is being recycled, remove old embedded controls UIView *viewToRemove = nil; viewToRemove = [cell.contentView viewWithTag:1]; if (viewToRemove) [viewToRemove removeFromSuperview]; } cell.textLabel.text = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"labelKey"]; UIControl *control = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"viewKey"]; [cell.contentView addSubview:control]; return cell; } }

    Read the article

  • populate UITableView from json

    - by mcgrailm
    Hello all working on my building my first iDevice app and I am trying to populate a UITableView with data from json result I can get it to load from plist array no propblem and I can even see my json the problem I'm having is that the UITableView never gets to see the json results please bare with me as this is first time with obj-c or anything like it in my .h file @interface TableViewViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> { NSArray *exercises; NSMutableData *responseData; } in my .m file - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return exercises.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //create a cell UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; // fill it with contnets cell.textLabel.text = [exercises objectAtIndex:indexPath.row]; // return it return cell; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { responseData = [[NSMutableData data] retain]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://url_to_json"]]; [[NSURLConnection alloc] initWithRequest:request delegate:self ]; // load from plist //NSString *myfile = [[NSBundle mainBundle] pathForResource:@"exercise" ofType:@"plist"]; //exercises = [[NSArray alloc] initWithContentsOfFile:myfile]; [super viewDidLoad]; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"Connection failed: %@", [error description]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; [responseData release]; NSDictionary *dictionary = [responseString JSONValue]; NSArray *response = [dictionary objectForKey:@"response"]; exercises = [[NSArray alloc] initWithArray:response]; }

    Read the article

  • UITableView, having problems changing accessory when selected

    - by zpasternack
    I'm using a UITableView to allow selection of one (of many) items. Similar to the UI when selecting a ringtone, I want the selected item to be checked, and the others not. I would like to have the cell selected when touched, then animated back to the normal color (again, like the ringtone selection UI). A UIViewController subclass is my table's delegate and datasource (not UITableViewController, because I also have a toolbar in there). I'm setting the accessoryType of the cells in cellForRowAtIndexPath:, and updating my model when cells are selected in didSelectRowAtIndexPath:. The only way I can think of to set the selected cell to checkmark (and clear the previous one) is to call [tableView reloadData] in didSelectRowAtIndexPath:. However, when I do this, the animating of the cell deselection is weird (a white box appears where the cell's label should be). If I don't call reloadData, of course, the accessoryType won't change, so the checkmarks won't appear. I suppose I could turn the animation off, but that seems lame. I also toyed with getting and altering the cells in didSelectRowAtIndexPath:, but that's a big pain. Any ideas? Abbreviated code follows... - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell* aCell = [tableView dequeueReusableCellWithIdentifier:kImageCell]; if( aCell == nil ) { aCell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:kImageCell]; } aCell.text = [imageNames objectAtIndex:[indexPath row]]; if( [indexPath row] == selectedImage ) { aCell.accessoryType = UITableViewCellAccessoryCheckmark; } else { aCell.accessoryType = UITableViewCellAccessoryNone; } return aCell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; selectedImage = [indexPath row] [tableView reloadData]; }

    Read the article

  • xcode may not respond to warning

    - by Frames84
    Hi all, Can't seem to get rid of a warning. The warning is: 'UIImage' may not respond to '-scaleToSize' above the @implmentation MyViewController I have this @implementation: @implementation UIImage (scale) -(UIImage*)scaleToSize:(CGSize)size { UIGraphicsBeginImageContext(size); [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; } @end Then I have MyViewController implementation @implementation TodayNewsTableViewController @synthesize dataList; ...... - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MainNewsCellIdentifier = @"MainNewsCellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: MainNewsCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: MainNewsCellIdentifier] autorelease]; } NSUInteger row = [indexPath row]; NSDictionary *stream = (NSDictionary *) [dataList objectAtIndex:row]; NSString *title = [stream valueForKey:@"title"]; if( ! [title isKindOfClass:[NSString class]] ) { cell.textLabel.text = @""; } else { cell.textLabel.text = title; } cell.textLabel.numberOfLines = 2; cell.textLabel.font =[UIFont systemFontOfSize:10]; cell.detailTextLabel.numberOfLines = 1; cell.detailTextLabel.font= [UIFont systemFontOfSize:8]; cell.detailTextLabel.text = [stream valueForKey:@"created"]; NSString *i = [NSString stringWithFormat:@"http://www.mywebsite.co.uk/images/%@", [stream valueForKey:@"image"]]; NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:i]]; UIImage *newsImage = [[UIImage alloc] initWithData:imageURL] ; UIImage *scaledImage = [newsImage scaleToSize:CGSizeMake(50.0f, 50.0f)]; // warning is appearing here. cell.imageView.image = scaledImage; [imageURL release]; [newsImage release]; return cell; } Thanks for your time in advance. Frames

    Read the article

  • Signal "0" error while scrolling a tableview with images

    - by Amitkumar
    Hi, I have a problem while scrolling images on tableview. I am getting a Signal "0" error. I think it is due to some memory issues but I am not able to find out the exact error. The code is as follows, - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [travelSummeryPhotosTable dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease]; } //Photo ImageView UIImageView *photoTag = [[UIImageView alloc] initWithFrame:CGRectMake(5.0, 5.0, 85.0, 85.0)]; NSString *rowPath =[[imagePathsDictionary valueForKey:[summaryTableViewDataArray objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]; photoTag.image = [UIImage imageWithContentsOfFile:rowPath]; [cell.contentView addSubview:photoTag]; [photoTag release]; // Image Caption UILabel *labelImageCaption = [[UILabel alloc] initWithFrame:CGRectMake(110.0, 15.0, 190.0, 50.0)]; labelImageCaption.textAlignment = UITextAlignmentLeft; NSString *imageCaptionText =[ [imageCaptionsDictionary valueForKey:[summaryTableViewDataArray objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]; labelImageCaption.text = imageCaptionText; [cell.contentView addSubview:labelImageCaption]; [labelImageCaption release]; return cell; } Thanks in advance.

    Read the article

  • iPhone: Cell imageViews repeating when loaded from url

    - by araid
    I'm developing a demo RSS reader for iPhone. I obviously have a tableview to display the feeds, and then a detailed view. Some of this feeds have a thumbnail that I want to display on cell.imageview of the table, and some don't. The problem is that when scrolling the table, loaded thumbnails start repeating on other cells, and I end up with a thumbnail on every cell. Here's a piece of my code. I may upload screenshots later - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: @"rssItemCell"]; if(nil == cell){ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"rssItemCell"]autorelease]; } BlogRss *item = [[[self rssParser]rssItems]objectAtIndex:indexPath.row]; cell.textLabel.text = [item title]; cell.detailTextLabel.text = [item description]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; // Thumbnail if exists if(noticia.imagePath != nil){ NSData* imageData; @try { imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:item.imagePath]]; } @catch (NSException * e) { //Some error while downloading data } @finally { item.image = [[UIImage alloc] initWithData:imageData]; [imageData release]; } } if(item.image != nil){ [[cell imageView] setImage:item.image]; } return cell; } Any help will be very appreciated.

    Read the article

  • Core data setReturnsDistinctResult not working

    - by Moze
    So i'm building a small application, it uses core data database of ~25mb size with 4 entities. It's for bus timetables. In one table named "Stop" there are have ~1300 entries of bus stops with atributes "name", "id", "longitude", "latitude" and couple relationships. Now there are many stops with same name but different coordinates and id. Search is implemented using NSPredicate. So I want to show all distinct stop names in table view, i'm using setReturnsDistinctResults with NSDictionaryResultType and setPropertiesToFetch. But setReturnsDistinctResult is not working and I'm still getting all entries. Heres code: - (NSFetchRequest *)fetchRequest { if (fetchRequest == nil) { fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Stop" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]]; [fetchRequest setSortDescriptors:sortDescriptors]; [fetchRequest setResultType:NSDictionaryResultType]; [fetchRequest setPropertiesToFetch:[NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"name"]]]; [fetchRequest setReturnsDistinctResults:YES]; DebugLog(@"fetchRequest initialized"); } return fetchRequest; } ///////////////////// - (NSFetchedResultsController *)fetchedResultsController { if (self.predicateString != nil) { self.predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", self.predicateString]; [self.fetchRequest setPredicate:predicate]; } else { self.predicate = nil; [self.fetchRequest setPredicate:predicate]; } fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:self.fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:sectionNameKeyPath cacheName:nil]; return fetchedResultsController; } ////////////// - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [[fetchedResultsController objectAtIndexPath:indexPath] valueForKey:@"name"]; return cell; }

    Read the article

  • Tableview not updating correctly after adding person

    - by tazboy
    I have to be missing something simple here but it escapes me. After the user enters a new person to a mutable array I want to update the table. The mutable array is the datasource. I believe my issue lies within cellForRowAtIndexPath. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TextFieldCell *customCell = (TextFieldCell *)[tableView dequeueReusableCellWithIdentifier:@"TextCellID"]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (indexPath.row == 0) { if (customCell == nil) { NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"TextFieldCell" owner:nil options:nil]; for (id currentObject in nibObjects) { if ([currentObject isKindOfClass:[TextFieldCell class]]) customCell = (TextFieldCell *)currentObject; } } customCell.nameTextField.delegate = self; cell = customCell; } else { if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; cell.textLabel.text = [[self.peopleArray objectAtIndex:indexPath.row-1] name]; NSLog(@"PERSON AT ROW %d = %@", indexPath.row-1, [[self.peopleArray objectAtIndex:indexPath.row-1] name]); NSLog(@"peopleArray's Size = %d", [self.peopleArray count]); } } return cell; } When I first load the view everything is great. This is what prints: PERSON AT ROW 0 = Melissa peopleArray's Size = 2 PERSON AT ROW 1 = Dave peopleArray's Size = 2 After I add someone to that array I get this: PERSON AT ROW 1 = Dave peopleArray's Size = 3 PERSON AT ROW 2 = Tom peopleArray's Size = 3 When I add a second person I get: PERSON AT ROW 2 = Tom peopleArray's Size = 4 PERSON AT ROW 3 = Ralph peopleArray's Size = 4 Why is not printing everyone in the array? This pattern continues and it only ever prints two people, and it's always the last two people. What the heck am I missing?

    Read the article

  • Strange XCode debugger behavior with UITableView datasource

    - by Tarfa
    Hey guys. I've got a perplexing issue. In my subclassed UITableViewController my datasource methods lose their tableview reference depending on lines of code I put inside the method. For example, in this code block: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return 5; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { id i = tableView; static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... return cell; } the "id i = tableView;" causes the tableview to become nil (0x0) -- and it causes it to be nil before I ever start stepping into the method. If I insert an assignment statement above the "id i = tableview;" statement: CGFloat x = 5.0; id i = tableView; then tableview retains its pointer (i.e. is not nil) if I place the breakpoint after the "id i = tableView;" line. In other words, the breakpoint must be set after the "id i = tableView"; assignment in order for tableView to retain its pointer. If the breakpoint is set before the assignment is made and I just hang at that breakpoint for a bit then after a couple of seconds the console logs this error message: Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, line 3990. Although the code works when I don't step through the method, I need my debugger to work! It makes programming kind of challenging when your debugging tools become your enemy. Anyone know what the cause and solution are? Thanks.

    Read the article

  • Why I got a "sent to freed object error"?

    - by Tattat
    I have a Table View, and CharTableController, the CharTableController works like this: .h: #import <Foundation/Foundation.h> @interface CharTableController : UITableViewController <UITableViewDelegate, UITableViewDataSource>{ // IBOutlet UILabel *debugLabel; NSArray *listData; } //@property (nonatomic, retain) IBOutlet UILabel *debugLabel; @property (nonatomic, retain) NSArray *listData; @end The .m: #import "CharTableController.h" @implementation CharTableController @synthesize listData; - (void)viewDidLoad { NSArray *array = [[NSArray alloc] initWithObjects:@"Sleepy", @"Sneezy", @"Bashful", @"Happy", @"Doc", @"Grumpy", @"Dopey", @"Thorin", @"Dorin", @"Nori", @"Ori", @"Balin", @"Dwalin", @"Fili", @"Kili", @"Oin", @"Gloin", @"Bifur", @"Bofur", @"Bombur", nil]; self.listData = array; [array release]; [super viewDidLoad]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.listData count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease]; NSUInteger row = [indexPath row]; cell.textLabel.text = [listData objectAtIndex:row]; } return cell; } @end And I Use the IB to link the TableView's dataSource and delegate to the CharTableController. In the CharTableController's view is the TableView in IB obviously. Reference Object in dataSource TableView and delegate TableView. What's wrong with my setting? thz.

    Read the article

  • How save selected switch option

    - by Rkm
    System UIviewcontroller has button , Tap on button i need to fire Info Tableviewcontroller. Tableviewcontroller itself UISwitch. My question is I need to save last selected switch option ON/OFF in UISwitch how to set my control. @implementation Info // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if (indexPath.section) { cell.textLabel.text = @"Sounds"; cell.selectionStyle = UITableViewCellSelectionStyleNone; UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; cell.accessoryView = switchView; [switchView setOn:NO animated:NO]; [switchView addTarget:self action:@selector(switchChanged_Sounds:) forControlEvents:UIControlEventValueChanged]; [switchView release]; return cell ; } } - (void) switchChanged_Sounds:(id)sender { UISwitch* switchControl = sender; NSLog( @"The switchChanged_Sounds is %@", switchControl.on ? @"ON" : @"OFF" ); }

    Read the article

  • UICollectionView with one static cell and N dynamic ones from a fetchresultscontroller exception

    - by nflacco
    I'm trying to make a UITableView that shows a blog post and comments for that post. My setup is a tableview in storyboard with two dynamic prototype cells. The first cell is for the post and should never change. The second cell represents the 0 to N comments. My cellForRowAtIndexPath method shows the post cell properly, but fails to get the comment at the given index path (though if I comment out the fetch I get the appropriate number of comment cells with a green background that I set as a visual debug thing). let comment = fetchedResultController.objectAtIndexPath(indexPath) as Comment I get the following exception on this line: 2014-08-24 15:06:40.712 MessagePosting[21767:3266409] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]' *** First throw call stack: ( 0 CoreFoundation 0x0000000101aa43e5 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001037f9967 objc_exception_throw + 45 2 CoreFoundation 0x000000010198f4c3 -[__NSArrayM objectAtIndex:] + 227 3 CoreData 0x00000001016e4792 -[NSFetchedResultsController objectAtIndexPath:] + 162 Section and cell setup: override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { // #warning Incomplete method implementation. // Return the number of rows in the section. switch section { case 0: return 1 default: if let realPost:Post = post { return fetchedResultController.sections[0].numberOfObjects } else { return 0 } } } override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { switch indexPath.section { case 0: let cell = tableView.dequeueReusableCellWithIdentifier(postViewCellIdentifier, forIndexPath: indexPath) as UITableViewCell cell.backgroundColor = lightGrey if let realPost:Post = self.post { cell.textLabel.text = realPost.text } return cell default: let cell = tableView.dequeueReusableCellWithIdentifier(commentCellIdentifier, forIndexPath: indexPath) as UITableViewCell cell.backgroundColor = UIColor.greenColor() let comment = fetchedResultController.objectAtIndexPath(indexPath) as Comment // <---------------------------- :( cell.textLabel.text = comment.text return cell } } FRC: func controllerDidChangeContent(controller: NSFetchedResultsController!) { tableView.reloadData() } func getFetchedResultController() -> NSFetchedResultsController { fetchedResultController = NSFetchedResultsController(fetchRequest: taskFetchRequest(), managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil) return fetchedResultController } func taskFetchRequest() -> NSFetchRequest { if let realPost:Post = self.post { let fetchRequest = NSFetchRequest(entityName: "Comment") let sortDescriptor = NSSortDescriptor(key: "date", ascending: false) fetchRequest.predicate = NSPredicate(format: "post = %@", realPost) fetchRequest.sortDescriptors = [sortDescriptor] return fetchRequest } else { return NSFetchRequest(entityName: "") } }

    Read the article

  • UITableView Inactive Until Scroll iPhone

    - by dubbeat
    HI, I'm trying to find the cause of some annoying behaviour with my UITableView. In each cell of my table (10 of them ) I asynchronously load an image. The problem is, is that if I don't touch the app at all the imageviews will permanently show a loading icon. However as soon as I scroll a cell off the screen and back on again the image shows straight away. What could be causing this "stuck in the mud" behaviour? Is there a way to force whatever gets called when the list is scrolled to make the needed update happen? #define ASYNC_IMAGE_TAG 9999 #define LABEL_TAG 8888 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PromoListItem *promo = [promoList objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"Cell"; AsyncImageView *asyncImageView = nil; UILabel *label = nil; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; CGRect frame; frame.origin.x = 0; frame.origin.y = 0; frame.size.width = 100; frame.size.height = 100; asyncImageView = [[[AsyncImageView alloc] initWithFrame:frame] autorelease]; asyncImageView.tag = ASYNC_IMAGE_TAG; [cell.contentView addSubview:asyncImageView]; frame.origin.x = 110; frame.size.width =100; label = [[[UILabel alloc] initWithFrame:frame] autorelease]; label.tag = LABEL_TAG; [cell.contentView addSubview:label]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } else { asyncImageView = (AsyncImageView *) [cell.contentView viewWithTag:ASYNC_IMAGE_TAG]; label = (UILabel *) [cell.contentView viewWithTag:LABEL_TAG]; } NSURL *url = [NSURL URLWithString:promo.imgurl]; [asyncImageView loadImageFromURL:url]; label.text = promo.artistname; return cell; }

    Read the article

  • Displaying Plist data into UItableview

    - by Christien
    I have a plist with Dictionary and numbers of strings per dictionary.show into the url below.and this list of items is in thousands in the plist. I need to display these plist data into the UItableview . How to do this? My Code: - (void)viewWillAppear:(BOOL)animated { // get paths from root direcory NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [documentPaths objectAtIndex:0]; NSString *documentPlistPath = [documentsDirectory stringByAppendingPathComponent:@"p.plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:documentPlistPath]; valueArray = [dict objectForKey:@"title"]; self.mySections=[valueArray copy]; NSLog(@"value array %@",self.mySections); } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.mySections count]; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { NSString *key = [[self.mySections objectAtIndex:section]objectForKey:@"pass"]; return [NSString stringWithFormat:@"%@", key]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 5; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } // Configure the cell... NSUInteger section = [indexPath section]; NSUInteger row = [indexPath row]; cell.textLabel.text = [[self.mySections objectAtIndex:row] objectForKey:@"title"]; cell.detailTextLabel.text=[[self.mySections objectAtIndex:section] objectForKey:[allKeys objectAtIndex:1]]; return cell; } Error is 2012-12-17 16:21:07.372 Project[2076:11603] * Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (4) beyond bounds (4)' * First throw call stack: (0x1703052 0x1523d0a 0x16aba78 0x16ab9e9 0x16fcc60 0x1d03a 0x391e0f 0x392589 0x37ddfd 0x38c851 0x337301 0x1704e72 0x277592d 0x277f827 0x2705fa7 0x2707ea6 0x2707580 0x16d79ce 0x166e670 0x163a4f6 0x1639db4 0x1639ccb 0x1505879 0x150593e 0x2f8a9b 0x2158 0x20b5) terminate called throwing an exceptionkill

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >