Search Results

Search found 183 results on 8 pages for 'textlabel'.

Page 1/8 | 1 2 3 4 5 6 7 8  | Next Page >

  • Changing UITableViewCell textLabel background color to clear

    - by SorinA.
    In my app i have a table view with customViewCells. i subclassed the UITableViewCell class and added an image that will load async and for the text i use cell.textLabel.text = @"someThext". for the cells the background color is set alternatively to [UIColor darkGrayColor] and whitecolor. When i run the app in the simulator and on the pone the textLabel of the cell has the background white. I want to set it to be clear, because i want the background color of the cell to be full not a strip then white then another strip. in the init method of my custom cell i added hoping that the white will turn into red but it doesn't have any effect. [self.textLabel setBackgroundColor:[UIColor redColor]]; i tried also self.textLabel.backgroundColor = [UIColor redColor]; but this also didn't work...if i add a UILabel as a subview the background color of the label can be set..but i don't want to do that because when i rotate the phone i want my labels to auto enlarge... any ideas why setting the background color of cell.textLabel doesn't work? thank you

    Read the article

  • iPhone Device 3.1 SDK Breaks vertical alignment of UITableViewCellStyleValue1 textLabel

    - by user171089
    Can anyone provide an explanation for the following phenomenon? As of the iPhone Device 3.1 SDK, I've found that if a UITableViewCell is of style UITableViewCellStyleValue1 and its detailTextLabel.text is unassigned, then the textLabel does not display in the center of the cell as would be expected. One notable caveat is that this only happens for me when I'm testing on the Device – the iPhone Simulator 3.1 SDK displays the cells correctly. Also, this is not a problem when using the iPhone Device 3.0 SDK. Below is a simple UITableView subclass implementation that demonstrates the problem. @implementation BuggyTableViewController #pragma mark Table view methods // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } // 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:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; } switch (indexPath.row) { case 0: cell.textLabel.text = @"detailTextLabel.text unassigned"; break; case 1: cell.textLabel.text = @"detailTextLabel.text = @\"\""; cell.detailTextLabel.text = @""; break; case 2: cell.textLabel.text = @"detailTextLabel.text = @\"A\""; cell.detailTextLabel.text = @"A"; break; default: break; } return cell; } @end

    Read the article

  • iPhone UITableViewCell: repositioning the textLabel

    - by user359784
    Hello, I am new to iPhone development and I am currently working on a simple RSS reader app. The problem I am having is that I need to reposition the textLabel inside the UITableViewCells. I have tried setFrame or setCenter but it doesn't do anything. Does anyone know what I need to do inside the tableView:cellForRowAtIndexPath: method to reposition the textLabel at the top of the cell (x = 0, y = 0)? Thank you PS: The UITableViewCell is referenced by a variable called cell. I have tried [cell setFrame:CGRectMake(0, 0, 320, 20)] with no success.

    Read the article

  • textLabel.backgroundColor on UITableViewCell does not work

    - by Tom
    Hi! I'm trying to set the label backgroundColor of my UITableViewCells and it does absolutely nothing at all. I wonder if there's another way of doing this, so I'm asking! I tried this: cell.textLabel.backgroundColor = [UIColor redColor]; cell.backgroundColor = [UIColor redColor]; And it doesn't work, anything else? Thanks!

    Read the article

  • iphone how to customize UITableViewCell cell.textlabel and cell.detailtextlabel programmatically

    - by Prerak
    Hi! In my iPhone App In table view cell I want to dispaly one main title and 5 subtitlessubtitles suppose item1 as main title and item2 , item3 , item4 , item5 and item6 as subtitles, for that i have saperate two arrays for passing the values in table view cell one for cell.textLabel.text= second for cell.detailTextLabel.text now I want the flexibility to make item2 as maintitle and want to add item1 to subtitle How can I set title and subtitle programmatically from single array? and any of them as Please Help and Suggest, Thank You.

    Read the article

  • TableView Background image going over cell textLabel

    - by Alex Trott
    Currently my tableview looks like this: as you can see, cell.textLabel and cell.detailTextLable both load this background, and i can't work out how to get them to stop loading the background, and for it only to be the backing on the cell. Here's my current code to change the cell: - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { [cell setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"tableCell.png"]]]; } How can i get round this problem? Thanks in advance.

    Read the article

  • UITabbleView Sections /cellForRowAtIndexPath method

    - by treasure
    hello, i have a sectioned tableview in a detailviewcontroller where i load some data in the first section. this is my code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; } // For the Ingredients section, if necessary create a new cell and configure it with an additional label for the amount. Give the cell a different identifier from that used for cells in other sections so that it can be dequeued separately. if (indexPath.section == PARAMETERS_SECTION) { switch(indexPath.row) { case 0: cell.textLabel.text = @"Pili"; cell.textLabel.numberOfLines = 1; cell.textLabel.textAlignment = UITextAlignmentLeft; cell.detailTextLabel.text = entity.stid; cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:12]; cell.detailTextLabel.numberOfLines = 2; break; case 1: cell.textLabel.text = @"Pele"; cell.textLabel.numberOfLines = 1; cell.textLabel.textAlignment = UITextAlignmentLeft; cell.detailTextLabel.text = entity.arec; cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:11]; cell.detailTextLabel.numberOfLines = 5; break; case 2: cell.textLabel.text = @"Pale"; cell.textLabel.numberOfLines = 1; cell.textLabel.textAlignment = UITextAlignmentLeft; cell.detailTextLabel.text = entity.wer; cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:11]; cell.detailTextLabel.numberOfLines = 3; break; case 3: cell.textLabel.text = @"Pole"; cell.textLabel.numberOfLines = 1; cell.textLabel.textAlignment = UITextAlignmentLeft; cell.detailTextLabel.text = entity.groid; cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:11]; cell.detailTextLabel.numberOfLines = 3; break; default: break; } if (indexPath.section == NOTES_SECTION) { NSString *text = nil; text = @"User Notes"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.editingAccessoryType = UITableViewCellAccessoryNone; cell.selectionStyle = UITableViewCellSelectionStyleBlue; cell.textLabel.text = text; } if (indexPath.section == EVALUATION_SECTION) { NSString *text = nil; text = @"Evaluation"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.editingAccessoryType = UITableViewCellAccessoryNone; cell.selectionStyle = UITableViewCellSelectionStyleBlue; cell.textLabel.text = text; } if (indexPath.section == CENTERING_SECTION) { NSString *text = nil; text = @"Centering"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.editingAccessoryType = UITableViewCellAccessoryNone; cell.selectionStyle = UITableViewCellSelectionStyleBlue; cell.textLabel.text = text; } } return cell; } everything works ok for the first section. the rest of them seem to be "ignored" Can someone help me? thank you!

    Read the article

  • Why does my UIButton.titleLabel.text disappear when I place an image in the button?

    - by nickthedude
    I've had this problem before but was able to work around it until now, Basically I'm creating a custom UIbutton setting its image as a uiimage and then the button that has had a label until I implimented the below code now loses its label. I need that label because it is set programatically in code that follows. NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ]; UIImage *image = [UIImage imageNamed:imageName]; [button setImage:image forState:UIControlStateNormal ]; Any help you could lend would be mucho appreciated. -nick

    Read the article

  • How do you change the textLabel when UITableViewCell is selected?

    - by Ike
    I want to change the textLabel and detailTextLabel of a cell when it has been selected. I've tried the following, but no change occurs: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MyAppDelegate *appDelegate = (MyPhoneAppDelegate*)[[UIApplication sharedApplication] delegate]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.detailTextLabel.text = @"xxxxx"; cell.textLabel.text = @"zzzzz"; [tableView reloadData]; }

    Read the article

  • is it possible to adjust position x,y titleLabel of UIButton ?

    - by RAGOpoR
    here is my code UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)]; [btn setTitle:[NSString stringWithFormat:@"Button %d", i+1] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; btn.titleLabel.frame = ???

    Read the article

  • Add UIView and UILabel to UICollectionViewCell. Then Segue based on clicked cell index

    - by JetSet
    I am new to collection views in Objective-C. Can anyone tell me why I can't see my UILabel embedded in the transparent UIView and the best way to resolve. I want to also segue from the cell to several various UIViewControllers based on the selected index cell. I am using GitHub project https://github.com/mayuur/MJParallaxCollectionView Overall, in MJRootViewController.m I wanted to add a UIView with a transparency and a UILabel with details of the cell from a array. MJCollectionViewCell.h // MJCollectionViewCell.h // RCCPeakableImageSample // // Created by Mayur on 4/1/14. // Copyright (c) 2014 RCCBox. All rights reserved. // #import <UIKit/UIKit.h> #define IMAGE_HEIGHT 200 #define IMAGE_OFFSET_SPEED 25 @interface MJCollectionViewCell : UICollectionViewCell /* image used in the cell which will be having the parallax effect */ @property (nonatomic, strong, readwrite) UIImage *image; /* Image will always animate according to the imageOffset provided. Higher the value means higher offset for the image */ @property (nonatomic, assign, readwrite) CGPoint imageOffset; //@property (nonatomic,readwrite) UILabel *textLabel; @property (weak, nonatomic) IBOutlet UILabel *textLabel; @property (nonatomic,readwrite) NSString *text; @property(nonatomic,readwrite) CGFloat x,y,width,height; @property (nonatomic,readwrite) NSInteger lineSpacing; @property (nonatomic, strong) IBOutlet UIView* overlayView; @end MJCollectionViewCell.m // // MJCollectionViewCell.m // RCCPeakableImageSample // // Created by Mayur on 4/1/14. // Copyright (c) 2014 RCCBox. All rights reserved. // #import "MJCollectionViewCell.h" @interface MJCollectionViewCell() @property (nonatomic, strong, readwrite) UIImageView *MJImageView; @end @implementation MJCollectionViewCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) [self setupImageView]; return self; } - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) [self setupImageView]; return self; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ #pragma mark - Setup Method - (void)setupImageView { // Clip subviews self.clipsToBounds = YES; // Add image subview self.MJImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, IMAGE_HEIGHT)]; self.MJImageView.backgroundColor = [UIColor redColor]; self.MJImageView.contentMode = UIViewContentModeScaleAspectFill; self.MJImageView.clipsToBounds = NO; [self addSubview:self.MJImageView]; } # pragma mark - Setters - (void)setImage:(UIImage *)image { // Store image self.MJImageView.image = image; // Update padding [self setImageOffset:self.imageOffset]; } - (void)setImageOffset:(CGPoint)imageOffset { // Store padding value _imageOffset = imageOffset; // Grow image view CGRect frame = self.MJImageView.bounds; CGRect offsetFrame = CGRectOffset(frame, _imageOffset.x, _imageOffset.y); self.MJImageView.frame = offsetFrame; } - (void)setText:(NSString *)text{ _text=text; if (!self.textLabel) { CGFloat realH=self.height*2/3-self.lineSpacing; CGFloat latoA=realH/3; // self.textLabel=[[UILabel alloc] initWithFrame:CGRectMake(10,latoA/2, self.width-20, realH)]; self.textLabel.layer.anchorPoint=CGPointMake(.5, .5); self.textLabel.font=[UIFont fontWithName:@"HelveticaNeue-ultralight" size:38]; self.textLabel.numberOfLines=3; self.textLabel.textColor=[UIColor whiteColor]; self.textLabel.shadowColor=[UIColor blackColor]; self.textLabel.shadowOffset=CGSizeMake(1, 1); self.textLabel.transform=CGAffineTransformMakeRotation(-(asin(latoA/(sqrt(self.width*self.width+latoA*latoA))))); [self addSubview:self.textLabel]; } self.textLabel.text=text; } @end MJViewController.h // // MJViewController.h // ParallaxImages // // Created by Mayur on 4/1/14. // Copyright (c) 2014 sky. All rights reserved. // #import <UIKit/UIKit.h> @interface MJRootViewController : UIViewController{ NSInteger choosed; } @end MJViewController.m // // MJViewController.m // ParallaxImages // // Created by Mayur on 4/1/14. // Copyright (c) 2014 sky. All rights reserved. // #import "MJRootViewController.h" #import "MJCollectionViewCell.h" @interface MJRootViewController () <UICollectionViewDataSource, UICollectionViewDelegate, UIScrollViewDelegate> @property (weak, nonatomic) IBOutlet UICollectionView *parallaxCollectionView; @property (nonatomic, strong) NSMutableArray* images; @end @implementation MJRootViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //self.navigationController.navigationBarHidden=YES; // Fill image array with images NSUInteger index; for (index = 0; index < 14; ++index) { // Setup image name NSString *name = [NSString stringWithFormat:@"image%03ld.jpg", (unsigned long)index]; if(!self.images) self.images = [NSMutableArray arrayWithCapacity:0]; [self.images addObject:name]; } [self.parallaxCollectionView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - UICollectionViewDatasource Methods - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.images.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MJCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MJCell" forIndexPath:indexPath]; //get image name and assign NSString* imageName = [self.images objectAtIndex:indexPath.item]; cell.image = [UIImage imageNamed:imageName]; //set offset accordingly CGFloat yOffset = ((self.parallaxCollectionView.contentOffset.y - cell.frame.origin.y) / IMAGE_HEIGHT) * IMAGE_OFFSET_SPEED; cell.imageOffset = CGPointMake(0.0f, yOffset); NSString *text; NSInteger index=choosed>=0 ? choosed : indexPath.row%5; switch (index) { case 0: text=@"I am the home cell..."; break; case 1: text=@"I am next..."; break; case 2: text=@"Cell 3..."; break; case 3: text=@"Cell 4..."; break; case 4: text=@"The last cell"; break; default: break; } cell.text=text; cell.overlayView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f]; //cell.textLabel.text = @"Label showing"; cell.textLabel.font = [UIFont boldSystemFontOfSize:22.0f]; cell.textLabel.textColor = [UIColor whiteColor]; //This is another attempt to display the label by using tags. //UILabel* label = (UILabel*)[cell viewWithTag:1]; //label.text = @"Label works"; return cell; } #pragma mark - UIScrollViewdelegate methods - (void)scrollViewDidScroll:(UIScrollView *)scrollView { for(MJCollectionViewCell *view in self.parallaxCollectionView.visibleCells) { CGFloat yOffset = ((self.parallaxCollectionView.contentOffset.y - view.frame.origin.y) / IMAGE_HEIGHT) * IMAGE_OFFSET_SPEED; view.imageOffset = CGPointMake(0.0f, yOffset); } } @end

    Read the article

  • How to programatically set cell.textLabel.text from a different view?

    - by Andy
    I've got a view controller, call it VC1, that's a table view. When I tap a cell in the table view, I am presented with a new view controller, call it VC2, which is a short list of choices. After making a choice, I want to dismiss VC2 and set the cell.textLabel.text property of the VC1 cell I originally tapped to the value I selected in VC2. Conceptually speaking, what is the proper way to do this? I've tried a handful of different approaches, but all of them seem wonky at best, and only one of them actually worked - although it was the most cumbersome of all, passing references to both view controllers and table view cells and all kinds of things. It just feels like I'm making a mountain out of what is probably a mole hill. This is such a common paradigm that I find it hard to believe there's not a simple method for doing it. Thanks in advance for any input you can offer.

    Read the article

  • cant populate cells with an array when i have loaded a second UITableViewController

    - by richard Stephenson
    hi there, im very new to iphone programming, im creating my first app, (a world cup one) the first view is a table view. the cell text label is filled with an array, so it shows all the groups (group a, B, c,ect) then when you select a group, it pulls on another UITableViewcontroller, but whatever i do i cant set the text label of the cells (e.g france,mexico,south africa, etc. infact nothin i do to the cellForRowAtIndexPath makes a difference , could someone tell me what im doing wrong please Thanks `here is my code for the view controller #import "GroupADetailViewController.h" @implementation GroupADetailViewController @synthesize groupLabel = _groupLabel; @synthesize groupADetail = _groupADetail; @synthesize teamsInGroupA; #pragma mark Memory management - (void)dealloc { [_groupADetail release]; [_groupLabel release]; [super dealloc]; } #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Set the number label to show the number data teamsInGroupA = [[NSArray alloc]initWithObjects:@"France",@"Mexico",@"Uruguay",@"South Africa",nil]; NSLog(@"loaded"); // Set the title to also show the number data [[self navigationItem]setTitle:@"Group A"]; //[[self navigationItem]cell.textLabel.text:@"test"]; //[[self navigationItem] setTitle[NSString String } - (void)viewDidUnload { [self setgroupLabel:nil]; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView { // Return the number of sections in the table view return 1; } - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in a specific section // Since we only have one section, just return the number of rows in the table return 4; NSLog:("count is %d",[teamsInGroupA count]); } - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *cellIdentifier2 = @"Cell2"; // Reuse an existing cell if one is available for reuse UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2]; // If no cell was available, create a new one if (cell == nil) { NSLog(@"no cell, creating"); cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier2] autorelease]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; } NSLog(@"cell already there"); // Configure the cell to show the data for this row //[[cell textLabel]setText:[NSString string //[[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; //NSUInteger row = [indexPath row]; //[cell setText:[[teamsInGroupA objectAtIndex:indexPath:row]retain]]; //cell.textLabel.text:@"Test" [[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; return cell; } @end #import "GroupADetailViewController.h" @implementation GroupADetailViewController @synthesize groupLabel = _groupLabel; @synthesize groupADetail = _groupADetail; @synthesize teamsInGroupA; #pragma mark Memory management - (void)dealloc { [_groupADetail release]; [_groupLabel release]; [super dealloc]; } #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Set the number label to show the number data teamsInGroupA = [[NSArray alloc]initWithObjects:@"France",@"Mexico",@"Uruguay",@"South Africa",nil]; NSLog(@"loaded"); // Set the title to also show the number data [[self navigationItem]setTitle:@"Group A"]; //[[self navigationItem]cell.textLabel.text:@"test"]; //[[self navigationItem] setTitle[NSString String } - (void)viewDidUnload { [self setgroupLabel:nil]; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView { // Return the number of sections in the table view return 1; } - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in a specific section // Since we only have one section, just return the number of rows in the table return 4; NSLog:("count is %d",[teamsInGroupA count]); } - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *cellIdentifier2 = @"Cell2"; // Reuse an existing cell if one is available for reuse UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2]; // If no cell was available, create a new one if (cell == nil) { NSLog(@"no cell, creating"); cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier2] autorelease]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; } NSLog(@"cell already there"); // Configure the cell to show the data for this row //[[cell textLabel]setText:[NSString string //[[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; //NSUInteger row = [indexPath row]; //[cell setText:[[teamsInGroupA objectAtIndex:indexPath:row]retain]]; //cell.textLabel.text:@"Test" [[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; return cell; } @end

    Read the article

  • UITableViewCell with UITableViewCellStyleValue1, adding new line to detailTextLabel at cell at botto

    - by slim
    on my tableview i have the last cell that is not initially visible as seen in the first image, when i scroll the list up, you can see in the second image that the price or my detailTextLabel is put on a new line not maintaining the right justification. Here is the code, i can't figure out why its doing this, any direction or help would be much appreciated - (UITableViewCell *)tableView:(UITableView *)ltableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [ltableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Configure the cell. NSUInteger indexRow = [indexPath row]; switch (indexRow) { case 0:{ NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet]; NSString *description = [[currentData objectForKey:@"Description"] stringByTrimmingCharactersInSet:set]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.accessoryType = UITableViewCellAccessoryNone; cellShift = 1; if (![description isEqualToString:@""]) { cell.textLabel.text = @""; cell.detailTextLabel.text = description; cell.detailTextLabel.numberOfLines = 2; } else { cell.textLabel.text = @""; cell.detailTextLabel.text = @""; cell.detailTextLabel.numberOfLines = 0; } break; } default:{ if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; } NSDictionary *item = [tableData objectAtIndex:(indexRow-cellShift)]; NSString *name = [item objectForKey:@"Name"]; if ([name length] > MaxVendorsLength ) { name = [NSString stringWithFormat:@"%@ ...",[name substringToIndex:MaxVendorsLength]]; } cell.textLabel.text = name; cell.textLabel.minimumFontSize = 12; NSString *priceString; float price = [[item objectForKey:@"Price"] floatValue]; //NSLog(@"| %@ | : | %@ |",[item objectForKey:@"Name"], [item objectForKey:@"Price"]); if (price != 0) { priceString = [[NSString alloc] initWithFormat:@"$%.2f",price]; } else { priceString = [[NSString alloc] initWithString:@"--"]; } cell.detailTextLabel.text = priceString; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; [priceString release]; break; } } cell.textLabel.font = [UIFont boldSystemFontOfSize:15]; cell.textLabel.minimumFontSize = 14; cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:15]; cell.detailTextLabel.minimumFontSize = 14; return cell; } Let me know if i need to post anything else to get help with this ???

    Read the article

  • TableViewCell autorelease error

    - by iAm
    OK, for two days now i have been trying to solve an error i have inside the cellForRowAtIndex method, let start by saying that i have tracked down the bug to this method, the error is [CFDictionary image] or [Not a Type image] message sent to deallocated instance. I know about the debug flags, NSZombie, MallocStack, and others, they helped me narrow it down to this method and why, but I do not know how to solve besides a redesign of the app UI. SO what am i trying to do, well for this block of code, displays a purchase detail, which contains items, the items are in there own section, now when in edit mode, there appears a cell at the bottom of the items section with a label of "Add new Item", and this button will present a modal view of the add item controller, item is added and the view returns to the purchase detail screen, with the just added item in the section just above the "add new Item" cell, the problem happens when i scroll the item section off screen and back into view the app crashes with EXC_BAD_ACCESS, or even if i don't scroll and instead hit the back button on the navBar, still the same error. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; switch (indexPath.section) { case PURCHASE_SECTION: { static NSString *cellID = @"GenericCell"; cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:cellID] autorelease]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } switch (indexPath.row) { case CATEGORY_ROW: cell.textLabel.text = @"Category:"; cell.detailTextLabel.text = [self.purchase.category valueForKey:@"name"]; cell.accessoryType = UITableViewCellAccessoryNone; cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator; break; case TYPE_ROW: cell.textLabel.text = @"Type:"; cell.detailTextLabel.text = [self.purchase.type valueForKey:@"name"]; cell.accessoryType = UITableViewCellAccessoryNone; cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator; break; case VENDOR_ROW: cell.textLabel.text = @"Payment:"; cell.detailTextLabel.text = [self.purchase.vendor valueForKey:@"name"]; cell.accessoryType = UITableViewCellAccessoryNone; cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator; break; case NOTES_ROW: cell.textLabel.text = @"Notes"; cell.editingAccessoryType = UITableViewCellAccessoryNone; break; default: break; } break; } case ITEMS_SECTION: { NSUInteger itemsCount = [items count]; if (indexPath.row < itemsCount) { static NSString *itemsCellID = @"ItemsCell"; cell = [tableView dequeueReusableCellWithIdentifier:itemsCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:itemsCellID] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; } singleItem = [self.items objectAtIndex:indexPath.row]; cell.textLabel.text = singleItem.name; cell.detailTextLabel.text = [singleItem.amount formattedDataDisplay]; cell.imageView.image = [singleItem.image image]; } else { static NSString *AddItemCellID = @"AddItemCell"; cell = [tableView dequeueReusableCellWithIdentifier:AddItemCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AddItemCellID] autorelease]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } cell.textLabel.text = @"Add Item"; } break; } case LOCATION_SECTION: { static NSString *localID = @"LocationCell"; cell = [tableView dequeueReusableCellWithIdentifier:localID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:localID] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; } cell.textLabel.text = @"Purchase Location"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.editingAccessoryType = UITableViewCellAccessoryNone; break; } default: break; } return cell; } the singleItem is of Modal Type PurchaseItem for core data now that i know what is causing the error, how do i solve it, I have tried everything that i know and some of what i dont know but still, no progress, please any suggestions as to how to solve this without redesign is my goal, perhaps there is an error i am doing that I cannot see, but if it's the nature of autorelease, than i will redesign.

    Read the article

  • is there a way to show Uitableviewcell selection on limited frame?

    - by Rahul Vyas
    i have a uitableview cell added some labels something like this - (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]; UIImage* myImage = [UIImage imageNamed:@"AccessoryForDealsMain.png"]; UIImageView *MyimageView = [[UIImageView alloc] initWithImage:myImage]; MyimageView.contentMode=UIViewContentModeScaleToFill; cell.accessoryView=MyimageView; [MyimageView release]; UILabel *BluePatti = [[UILabel alloc] init]; BluePatti.frame=CGRectMake(0,0,4,44); BluePatti.backgroundColor = BLUEPATTI;//[UIColor blueColor]; UILabel *BlackLine = [[UILabel alloc] init]; BlackLine.frame=CGRectMake(3,0,1, 45); BlackLine.backgroundColor = BLACK_LINE; [BluePatti addSubview:BlackLine]; [BlackLine release]; [cell.contentView addSubview:BluePatti]; [BluePatti release]; UILabel *Seperator = [[UILabel alloc] initWithFrame:CGRectZero]; Seperator.backgroundColor = [UIColor colorWithRed:234/256.0 green:234/256.0 blue:234/256.0 alpha:1.0]; //[UIColor lightGrayColor]; Seperator.frame = CGRectMake(4,43,316,1); [cell.contentView addSubview:Seperator]; [Seperator release]; } if(indexPath.section==5) { cell.textLabel.text=[self.GenderCellData objectAtIndex:indexPath.row]; cell.textLabel.textColor=CELL_TEXT_COLOR; cell.textLabel.font=CELL_FONT; } else { cell.textLabel.text=@"Cells"; cell.textLabel.font=CELL_FONT; } return cell; } now when i touch cell it shows blue selection above all subviews.How do i change selection frame and colour?

    Read the article

  • Need help with memory leaks in RSS Reader

    - by Stilton
    I'm trying to write a simple RSS reader for the iPhone, and it appeared to be working fine, until I started working with Instruments, and discovered my App is leaking massive amounts of memory. I'm using the NSXMLParser class to parse an RSS feed. My memory leaks appear to be originating from the overridden delegate methods: - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string and - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName I'm also suspicious of the code that populates the cells from my parsed data, I've included the code from those methods and a few other key ones, any insights would be greatly appreciated. - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if ([self.currentElement isEqualToString:@"title"]) { [self.currentTitle appendString:string]; } else if ([self.currentElement isEqualToString:@"link"]) { [self.currentURL appendString:string]; } else if ([self.currentElement isEqualToString:@"description"]) { [self.currentSummary appendString:string]; } } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"item"]) { //asdf NSMutableDictionary *item = [[NSMutableDictionary alloc] init]; [item setObject:currentTitle forKey:@"title"]; [item setObject:currentURL forKey:@"URL"]; [item setObject:currentSummary forKey:@"summary"]; [self.currentTitle release]; [self.currentURL release]; [self.currentSummary release]; [self.stories addObject:item]; [item release]; } } // 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. // Set up the cell int index = [indexPath indexAtPosition: [indexPath length] - 1]; CGRect contentRect = CGRectMake(8.0, 4.0, 260, 20); UILabel *textLabel = [[UILabel alloc] initWithFrame:contentRect]; if (self.currentLevel == 0) { textLabel.text = [self.categories objectAtIndex: index]; } else { textLabel.text = [[self.stories objectAtIndex: index] objectForKey:@"title"]; } textLabel.textColor = [UIColor blackColor]; textLabel.font = [UIFont boldSystemFontOfSize:14]; [[cell contentView] addSubview: textLabel]; //[cell setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]]; [textLabel autorelease]; return cell; } - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if ([elementName isEqualToString:@"item"]) { self.currentTitle = [[NSMutableString alloc] init]; self.currentURL = [[NSMutableString alloc] init]; self.currentSummary = [[NSMutableString alloc] init]; } if (currentElement != nil) { [self.currentElement release]; } self.currentElement = [elementName copy]; } - (void)dealloc { [currentElement release]; [currentTitle release]; [currentURL release]; [currentSummary release]; [currentDate release]; [stories release]; [rssParser release]; [storyTable release]; [super dealloc]; } // Override to support row selection in the table view. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here -- for example, create and push another view controller. // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; int index = [indexPath indexAtPosition: [indexPath length] - 1]; if (currentLevel == 1) { StoryViewController *storyViewController = [[StoryViewController alloc] initWithURL:[[stories objectAtIndex: index] objectForKey:@"URL"] nibName:@"StoryViewController" bundle:nil]; [self.navigationController pushViewController:storyViewController animated:YES]; [storyViewController release]; } else { RootViewController *rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; rvController.currentLevel = currentLevel + 1; rvController.rssIndex = index; [self.navigationController pushViewController:rvController animated:YES]; [rvController release]; } }

    Read the article

  • What is the proper way of hard-coding sections in a UITableView?

    - by Sheehan Alam
    I have a UITableView with 3 sections that are hard coded. Everything is working fine, but I am not sure if I am doing it correctly. Define number of rows in section: - (NSInteger)tableView:(UITableView *)tblView numberOfRowsInSection:(NSInteger)section { NSInteger rows; //Bio Section if(section == 0){ rows = 2; } //Profile section else if(section == 1){ rows = 5; } //Count section else if(section == 2){ rows = 3; } } return rows; } Here is where I build my cells: - (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tblView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.numberOfLines = 5; cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:(10.0)]; cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; if ([self.message_source isEqualToString:@"default"]) { if (indexPath.section == 0) { if (indexPath.row == 0) { cell.textLabel.text = [Utils formatMessage:[NSString stringWithFormat: @"%@", mySTUser.bio]]; cell.detailTextLabel.text = nil; } else if(indexPath.row == 1){ cell.textLabel.text = [NSString stringWithFormat: @"%@", mySTUser.website]; cell.detailTextLabel.text = nil; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } } } //more code exists, but you get the point... Now I define my number of sections - (NSInteger)numberOfSectionsInTableView:(UITableView *)tblView { return 3; } Is this the proper way of hard-coding my UITableView? Will I run into any issues when cells are reused?

    Read the article

  • cellForRowAtIndexPath not called for all sections

    - by Wynn
    I have a UITableView that has five sections. Just as the title describes cellForRowAtIndexPath is only being called for the first four. All connections have been made concerning the datasource and delegate. Also, my numberOfSectionsInTableView clearly returns 5. Printing out the number of sections from within cellForRowAtIndexPath shows the correct number, thus confirming that cellForRowAtIndexPath is simply not being called for all sections. What on earth is going on? I looked pretty hard for an answer to this question but could't find one. If this has already been answered please forgive me and point me in the correct direction. My cellForRowAtIndexPath: - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } switch (indexPath.section) { case 0: cell.textLabel.text = ticket.description; break; case 1: cell.textLabel.text = ticket.ticketStatus; break; case 2: cell.textLabel.text = ticket.priority; break; case 3: cell.textLabel.text = ticket.customerOfficePhone; break; case 4: { //This never ever gets executed Comment *comment = [ticket.comments objectAtIndex:indexPath.row]; cell.textLabel.text = comment.commentContent; break; } } return cell; } My numberOfSectionsInTableView: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 5; } My numberOfRowsInSection: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger numberOfRows; if (section == 4) { numberOfRows = [ticket.comments count]; } else { numberOfRows = 1; } return numberOfRows; } Any suggestions are appreciated. Thanks in advance.

    Read the article

  • App is crashing as soon as UITableView gets reloaded

    - by OhhMee
    Hello, I'm developing an app where TableView needs to reload as soon as the login process gets completed. The app crashes with error EXC_BAD_ACCESS when the table data gets reloaded. It doesn't crash when I remove all case instances except case 0: What could be the reason behind it? Here's the code: - (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginDone:) name:@"loginDone" object:nil]; statTableView.backgroundColor = [UIColor clearColor]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { return 6; } - (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]; } // Configure the cell. switch (indexPath.row) { case 0 : cell.textLabel.text = @"Foo:"; NSLog(@"%@", data7); UILabel *myLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 20, 30)]; myLabel2.text = (@"%@", data7); myLabel2.textColor = [UIColor blackColor]; myLabel2.backgroundColor = [UIColor whiteColor]; myLabel2.font = [UIFont fontWithName:@"Trebuchet MS" size:14]; [cell.contentView addSubview:myLabel2]; break; case 1: cell.textLabel.text = @"Foo: "; UILabel *myLabel4 = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 20, 30)]; myLabel4.text = (@"%@", data11); myLabel4.textColor = [UIColor blackColor]; myLabel4.backgroundColor = [UIColor whiteColor]; myLabel4.font = [UIFont fontWithName:@"Trebuchet MS" size:14]; [cell.contentView addSubview:myLabel4]; break; case 2: cell.textLabel.text = @"Foo: "; UILabel *myLabel8 = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 20, 30)]; myLabel8.text = (@"%@", data3); myLabel8.textColor = [UIColor blackColor]; myLabel8.backgroundColor = [UIColor whiteColor]; myLabel8.font = [UIFont fontWithName:@"Trebuchet MS" size:14]; [cell.contentView addSubview:myLabel8]; break; case 3: cell.textLabel.text = @"Foo: "; UILabel *myLabel10 = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 20, 30)]; myLabel10.text = [NSString stringWithFormat:@"%@", data4]; if ([data4 isEqualToString:@"0"]) { myLabel10.text = @"None"; } myLabel10.textColor = [UIColor blackColor]; myLabel10.backgroundColor = [UIColor whiteColor]; myLabel10.font = [UIFont fontWithName:@"Trebuchet MS" size:14]; [cell.contentView addSubview:myLabel10]; break; case 4: cell.textLabel.text = @"Foo: "; UILabel *myLabel12 = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 20, 30)]; myLabel12.text = [NSString stringWithFormat:@"%@", data5]; myLabel12.textColor = [UIColor blackColor]; if ([data5 isEqualToString:@"Foo"]) { myLabel12.textColor = [UIColor redColor]; myLabel12.text = @"Nil"; } myLabel12.backgroundColor = [UIColor whiteColor]; myLabel12.font = [UIFont fontWithName:@"Trebuchet MS" size:14]; [cell.contentView addSubview:myLabel12]; break; case 5: cell.textLabel.text = @"Foo: "; UILabel *myLabel14 = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 50, 30)]; if ([data6 isEqualToString:@"Foo"]) { myLabel14.textColor = [UIColor colorWithRed:(0/255.f) green:(100/255.f) blue:(0/255.f) alpha:1.0]; myLabel14.text = @"No Dues"; } else { myLabel14.text = [NSString stringWithFormat:@"%@", data6]; myLabel14.textColor = [UIColor redColor]; } myLabel14.backgroundColor = [UIColor whiteColor]; myLabel14.font = [UIFont fontWithName:@"Trebuchet MS" size:14]; [cell.contentView addSubview:myLabel14]; break; /* [myLabel2 release]; [myLabel4 release]; [myLabel8 release]; [myLabel10 release]; [myLabel12 release]; [myLabel14 release]; */ } return cell; }

    Read the article

  • Issues adding search to iPhone app

    - by Graeme
    Hi, Basically I'm trying to add a search function to my iPhone app, but I'm not having much luck at the moment. I've downloaded the Apple provided Table Search app, and have copied across the code to mine. It builds OK, but here's the problem. Unlike the Apple example, all my data is stored in an array, that is accessed by calling [ciParser.currentArray]. Any ideas on how to change the code to suit my needs? I'm getting an error "Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'" whenever I click on the search bar and the app exits. Below is the code in particular that the debugger highlights as being troublesome. Apparently this error means the database trying to be searched is empty, but I could be wrong. FYI my app downloads and parsers an RSS feed using a class which is referenced by ciParser - which in turn stores the downloaded content in an array that I need to search. // 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 the requesting table view is the search display controller's table view, configure the cell using the filtered content, otherwise use the main list. */ CurrentItem * nextCurrentItem=[ciParser.currentArray objectAtIndex:indexPath.row]; if (tableView == self.searchDisplayController.searchResultsTableView) { (Code which debugger points to as being wrong) nextCurrentItem = [self.filteredListContent objectAtIndex:indexPath.row]; } else { nextCurrentItem = [ciParser.currentArray objectAtIndex:indexPath.row]; } NSString*settingValue = [[NSUserDefaults standardUserDefaults]stringForKey:@"state"]; if ([settingValue isEqualToString:@"New South Wales"]) { cell.textLabel.text=nextCurrentItem.title; } else if ([settingValue isEqualToString:@"Western Australia"]) { cell.textLabel.text=@"The FESA does not provide any Current Incident reports."; } else if ([settingValue isEqualToString:@"Victoria"]) { cell.textLabel.text=nextCurrentItem.title; } else if ([settingValue isEqualToString:@"South Australia"]) { cell.textLabel.text=nextCurrentItem.title; } else if ([settingValue isEqualToString:@"Tasmania"]) { cell.textLabel.text=nextCurrentItem.title; } // Set up the cell... [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; return cell; }

    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

  • Iphone xcode simulator crashes when I move up and down on a table row

    - by Frames84
    I can't get my head round this. When the page loads, everything works fine - I can drill up and down, however 'stream' (in the position I have highlighted below) becomes not equal to anything when I pull up and down on the tableview. But the error is only sometimes. Normally it returns key/pairs. If know one can understand above how to you test for // (int)[$VAR count]} key/value pairs in a NSMutableDictionary object - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *FirstLevelCell = @"FirstLevelCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstLevelCell] autorelease]; } NSInteger row = [indexPath row]; //NSDictionary *stream = (NSDictionary *) [dataList objectAtIndex:row]; NSString *level = self.atLevel; if([level isEqualToString:@"level2"]) { NSMutableDictionary *stream = [[NSMutableArray alloc] init]; stream = (NSMutableDictionary *) [dataList objectAtIndex:row]; // stream value is (int)[$VAR count]} key/value pairs if ([stream valueForKey:@"title"] ) { cell.textLabel.text = [stream valueForKey:@"title"]; cell.textLabel.numberOfLines = 2; cell.textLabel.font =[UIFont systemFontOfSize:10]; NSString *detailText = [stream valueForKey:@"created"]; cell.detailTextLabel.numberOfLines = 2; cell.detailTextLabel.font= [UIFont systemFontOfSize:9]; cell.detailTextLabel.text = detailText; NSString *str = @"http://www.mywebsite.co.uk/images/stories/Cimex.jpg"; NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:str]]; UIImage *newsImage = [[UIImage alloc] initWithData:imageURL]; cell.imageView.image = newsImage; [stream release]; } } else { cell.textLabel.text = [dataList objectAtIndex:row]; } return cell; } Thanks for your time

    Read the article

1 2 3 4 5 6 7 8  | Next Page >