No Icon came up next to the name on the UITableView - ios

Sorry if this turned out to be a stupid question~
Here is my Code in the UITableViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell....
cell.textLabel.text = [[[friendList friends] objectAtIndex:indexPath.row] profileName];
cell.imageView.image = [UIImage imageNamed:#"Zaka.jpg"];
return cell;
}
The List of Names did popped up but there's no icon next to any of it.

Related

How to use multiple cell.textLabel.text for multiple tableview?

I am trying to create two tableviews into one single UIViewController, Here I have created two tableview with If conditional statement to operate separate process for separate tables. But the problem is I need to create separate cell.textLabel.text for separate tables. Whenever I clicked the cell I am getting first Tableview cell.textLabel.text value.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView==tableone)
{
static NSString *cellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.textLabel.text = [....]; // Here I am applying first table values
}
if (tableView==tabletwo) {
static NSString *cellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.textLabel.text = [....]; // here I am applying my values
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (tableView==tableone) {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
cellText = selectedCell.textLabel.text;
NSLog(#"%#",cellText);
}
if (tableView==tabletwo) {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
cellText = selectedCell.textLabel.text;
NSLog(#"%#",cellText);
}
}
You can give tag of the tableview in utility view.
after giving tag you can use tableview using given particular tag.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.tag == 1)
{
static NSString *cellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.textLabel.text = [....];
}
if (tableView.tag ==2) {
static NSString *cellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.textLabel.text = [....];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (tableView.tag == 1) {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
cellText = selectedCell.textLabel.text;
NSLog(#"%#",cellText);
}
if (tableView.tag == 2) {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
cellText = selectedCell.textLabel.text;
NSLog(#"%#",cellText);
}
}
// I think this will help you..

Custom UITableViewCell abandoned memory issue on Select

I'm having an issue on iOS using a custom UITableView with a custom UITableViewCell. When I run the app on the Xcode Instruments I can see that there is an abandoned memory issue each time I select a cell from the custom TableView.
Please see the below a screen shot of the "Instruments".
http://i.stack.imgur.com/cKz22.png
Below is the code used to create a cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath2:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = [NSString stringWithFormat :#"cellID%i",indexPath.row];
customViewCell *cell = (customViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSInteger cellIndex = [indexPath row];
NSString* cellName = #"cell Name";
NSString* keyFile = #"0_48_video_1F0423D5-D2D7-466E-8D45-38C46E9B4425.mp4_1423522824.133377";
cell = [[customViewCell alloc] initWithStyle:UITableViewCellSelectionStyleNone reuseIdentifier:cellIdentifier withKeyFile:keyFile andRicochetName:ricochetName fromTableViewController:self;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
I would appreciate any expertise on helping identifying the memory issue. Please note that the App is built on ARC.
Thanks a lot
If you just have to pass keyFile name you use this way. Make sure you have linked keyFile in interface builder
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath2:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = #"cellID";
customViewCell *cell = (customViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
NSInteger cellIndex = [indexPath row];
NSString* cellName = #"cell Name";
NSString* keyFile = #"0_48_video_1F0423D5-D2D7-466E-8D45-38C46E9B4425.mp4_1423522824.133377";
cell.keyFile=keyFile;
return cell;
}
change the cell identifier to a static string.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath2:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = #"your tableview Cell Identifier";
customViewCell *cell = (customViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSString* cellName = #"cell Name";
NSString* keyFile = #"0_48_video_1F0423D5-D2D7-466E-8D45-38C46E9B4425.mp4_1423522824.133377";
cell = [[customViewCell alloc] initWithStyle:UITableViewCellSelectionStyleNone reuseIdentifier:cellIdentifier withKeyFile:keyFile andRicochetName:ricochetName fromTableViewController:self;
}
return cell;
}

UItableViewCell not dequeing properly ios

Using UITableView and found that cells are not dequeuing properly.
Here is the code which i have written.I have read that, have to override prepareForReuse, but how to use that method, not getting. Please help me out.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"cell";
cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
textLabel = (UILabel*)[cell viewWithTag:11];
textLabel.font=[UIFont fontWithName:#"MyUnderwood" size:16];
textLabel.text = [_tableLabelArray objectAtIndex:indexPath.row];
return cell;
}
Here is the image of UITableView which i am getting when i scroll the TableView
I am not sure if this will fix your issue, but this code uses a local UICell * variable, uses self.tableLabelArray rather than accessing the property iVar directly and uses the textLabel property rather than searching by tag.
My suspicion is that your cell variable is an iVar, not a local so that may be causing you problems, and therefore this may help, but it could also be that you need a font size smaller than 16, so I have specified adjustsFontSizeToFitWidth=YES
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"cell";
UITableViewCell *returnCell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (returnCell==nil) {
returnCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
returnCell.textLabel.font=[UIFont fontWithName:#"MyUnderwood" size:16];
returnCell.adjustsFontSizeToFitWidth=YES;
returnCell.text = [self.tableLabelArray objectAtIndex:indexPath.row];
return returnCell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"cell";
UITableViewCell *cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.text = [_tableLabelArray objectAtIndex:indexPath.row];
cell.textLabel.font=[UIFont fontWithName:#"MyUnderwood" size:16];
return cell;
}

Table View not populating objects

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"GenusNameCell";
GenusNameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[GenusNameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"GenusNameCell"];
cell.GenusNameLabel.text = [genusName objectAtIndex:indexPath.row];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
return cell;
}
I have a tableview with an Array of objects but when I run it. Nothing shows up. Im fairly new to xcode but Im not sure what my mistake is in the code. Can some one help me out?
If the cellForRowAtIndexPath callback is never called, it could be:
you didn't have set the dataSource of your tableview;
you didn't implement the numberOfSectionsInTableView: and/or tableView:numberOfRowsInSection: callbacks.
And if you dequeue your cell, you need to set the text outside the if branch like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"GenusNameCell";
GenusNameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[GenusNameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"GenusNameCell"];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
cell.GenusNameLabel.text = [genusName objectAtIndex:indexPath.row];
return cell;
}
Change the code like this your code will run,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"GenusNameCell";
GenusNameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[GenusNameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"GenusNameCell"];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
cell.GenusNameLabel.text = [[genusName objectAtIndex:indexPath.row] geniusname];
return cell;
}
geniusname is the NSString you stored the name of the person.

cellForRowIndexPath without cellidentifier ios

I do not have xib files or storyboards in my project. In this case how do I set the cell identifier? Below is my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(#"test");
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [self.entries objectAtIndex:indexPath.row];
return cell;
}
Try to replace you code by this (using ARC) :
- (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];
cell.textLabel.text = [self.entries objectAtIndex:indexPath.row];
return cell;
}
++
If you're just using a UITableViewCell for your table view, you can register that class in viewDidLoad like this:
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:#"Cell"];
Use the same identifier in cellForRowAtIndexPath: that you use here.

Resources