Value On UITextField Changes On Scroll - ios

Before asking this question I have googled a lot and not able to find a suitable answer.
I have a tableView with Three sections and n number of columns. The no. of rows in each section is also not fixed. The last two columns contains a UITextField and initially the value in each textfield is 0.00. So after entering the Value in each row if I close that section the textField value is revert back to 0.00. Can anybody tell me how to save this textField value.
Here is my code.
I'm using a custom Cell GenericTableViewCell and self.columnHeaderArray determines how many columns in tableview. columnHeaderArray Value contains the colum details like the column type, value etc...
in cellForRowAtIndexPath:
GenericTableViewCell *cell = nil;
if (cell == nil)
{
cell = [[GenericTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"Cell"withColumns:self.columnHeaderArray];
for (GenericTableColumn *theColumn in self.columnHeaderArray)
{
[self processDataForCell:cell forColumn:theColumn atIndexPath:indexPath];
}
return cell;
}
}
processDataForCell is a method where I updated the column with values and textfield. In this method I check the column type and insert values into each column.
The code for that is.
switch (column.columnType)
{
case textField:
{
UITextField *lblTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 4, label.frame.size.width - 10, label.frame.size.height - 6)];
lblTextField.delegate = self;
lblTextField.text = theValue; // setting the textField value iniatally 0.00
lblTextField.borderStyle = UITextBorderStyleRoundedRect;
lblTextField.layer.borderWidth = 1.0;
lblTextField.layer.borderColor = [[UIColor blackColor] CGColor];
[label addSubview:lblTextField];
break;
}
}
Any help would be greatly appreciated.
EDIT: I solved the issue thanks to #Ayazmon and #naturalnOva for their comments and leading me to solve this.
The Code:
In my .h file I declared a NSMutableDictionary named textFieldValues like
#property (nonatomic, strong) NSMutableDictionary <NSString *, NSString *> *textFieldValues;
And in viewDidLoad I instantiate this Dictionary as
self.textFieldValues = [NSMutableDictionary new];
In processDataForCell method I replaced my code with
switch (column.columnType)
{
case textField:
{
UITextField *lblTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 4, label.frame.size.width - 10, label.frame.size.height - 6)];
lblTextField.delegate = self;
lblTextField.tag = indexPath.row;
if ([self.textFieldValues count] != 0) {
// pass in the indexPath from cellForRow
NSString *key = [NSString stringWithFormat: #"%ld-%ld", (long)indexPath.section, (long)indexPath.row];
lblTextField.text = self.textFieldValues[key];
} else {
lblTextField.text = theValue; // For setting the textField value iniatally 0.00
}
lblTextField.borderStyle = UITextBorderStyleRoundedRect;
lblTextField.layer.borderWidth = 1.0;
lblTextField.layer.borderColor = [[UIColor blackColor] CGColor];
[label addSubview:lblTextField];
break;
}
}
And for me UITextField delegate method textFieldShouldEndEditing(_:) is not being called. So I used textFieldShouldReturn method.
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
NSString *key = [NSString stringWithFormat: #"%ld-%ld", (long)indexPath.section, (long)indexPath.row];
self.textFieldValues[key] = textField.text;
return self.textFieldValues[key];
}
Thanku Guys

As you scroll your cell's off view they are deallocated. Each time the cell scrolls back into view it's re-initialized. If you want to retain the value of the textfield I'd save it's contents when you can and hold onto that value.
I have done this before by holding on to a dictionary of Strings that contain the values for my indexPaths. Each time the textfield resigns as first responder I then store the value of the field in my dictionary.
You should register the UITextField's delegate in your view controller and override textFieldDidEndEditing(_:) where you can access the value of the textfield.
Example:
Create a property for the field values:
#property (nonatomic, strong) NSMutableDictionary *textFieldValues;
Override the UITextFieldDelegate method:
-(void) textFieldDidEndEditing: (UITextField *)textField
{
NSString *key = [NSString stringWithFormat: #"%ld-%ld", (long)indexPath.section, (long)indexPath.row];
self.textFieldValues[key] = textField.text;
}
Using your above code, assign a tag to the textfield and assign the fields contents using the dictionary:
UITextField *lblTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 4, label.frame.size.width - 10, label.frame.size.height - 6)];
lblTextField.delegate = self;
lblTextField.tag = indexPath.row;
// pass in the indexPath from cellForRow
NSString *key = [NSString stringWithFormat: #"%ld-%ld", (long)indexPath.section, (long)indexPath.row];
lblTextField.text = self.textFieldValues[key];
lblTextField.borderStyle = UITextBorderStyleRoundedRect;
lblTextField.layer.borderWidth = 1.0;
lblTextField.layer.borderColor = [[UIColor blackColor] CGColor];
[label addSubview:lblTextField];
Hope that helps.

cellForRowAtIndexPath is called whenever you try to display a cell in UITableView and in your code you create a completely new cell for the given indexPath every time. So when you set the value to the lblTextField and then displaying it again it gets resetted. My advice is restore the value then in processDataForCell method set the restored value to lblTextField that way the value will have consistency.

Related

How to get custom TableViewCell value on view controller without using button and set it after reload table in objective c

I am new in iOS and I am facing problem regarding to get the value from custom table view cell to view controller. I am using rate view for rating and I am checking if value of rate is less then 3 then it show have to enter text in the text view and I want to get value in view controller
My code is like this
CustomTableviewcell.h
#interface NextTableview : UITableViewCell<RateViewDelegate,UITextViewDelegate>
{
NSString *StatusValue;
UILabel *lbl;
}
#property(nonatomic,strong) IBOutlet UILabel *staticlbl;
#property(nonatomic,strong) IBOutlet UITextView *commenttxtview;
#property(nonatomic,strong) IBOutlet UILabel *Kpiidlbl;
#property (weak, nonatomic) IBOutlet RateView *rateView;
#property (weak, nonatomic) IBOutlet UILabel *statusLabel;
#end
CustomTableviewcell.m
#synthesize rateView,staticlbl,statusLabel,commenttxtview,Kpiidlbl;
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
commenttxtview.layer.borderWidth = 0.70f;
commenttxtview.layer.borderColor = [[UIColor blackColor] CGColor];
commenttxtview.delegate=self;
UIToolbar* doneToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
doneToolbar.barStyle = UIBarStyleBlackTranslucent;
doneToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:#"Done" style:UIBarButtonItemStyleDone target:self action:#selector(doneButtonClickedDismissKeyboard)],
nil];
[doneToolbar sizeToFit];
commenttxtview.inputAccessoryView = doneToolbar;
lbl = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0,90.0, 34.0)];
[lbl setText:#"Enter Text"];
[lbl setFont:[UIFont systemFontOfSize:12]];
[lbl setBackgroundColor:[UIColor clearColor]];
[lbl setTextColor:[UIColor lightGrayColor]];
commenttxtview.delegate = self;
[commenttxtview addSubview:lbl];
statusLabel.hidden=YES;
commenttxtview.hidden=YES;
// Do any additional setup after loading the view from its nib.
self.rateView.notSelectedImage = [UIImage imageNamed:#"not_selected_star#2x.png"];
self.rateView.halfSelectedImage = [UIImage imageNamed:#"half_selected_star#2x.png"];
self.rateView.fullSelectedImage = [UIImage imageNamed:#"selected_star#2x.png"];
self.rateView.rating = 0;
self.rateView.editable = YES;
self.rateView.maxRating = 5;
self.rateView.delegate = self;
Kpiidlbl.hidden=YES;
}
-(void)doneButtonClickedDismissKeyboard
{
[commenttxtview resignFirstResponder];
// commenttxtview.hidden=YES;
}
- (void)textViewDidEndEditing:(UITextView *)theTextView
{
if (![commenttxtview hasText]) {
lbl.hidden = NO;
}
}
- (void) textViewDidChange:(UITextView *)textView
{
if(![commenttxtview hasText]) {
lbl.hidden = NO;
}
else{
lbl.hidden = YES;
}
}
- (void)rateView:(RateView *)rateView ratingDidChange:(int)rating {
self.statusLabel.text = [NSString stringWithFormat:#"%d", rating];
NSLog(#"Rating value =%#",self.statusLabel.text);
StatusValue=statusLabel.text;
NSLog(#"Status Value String =%#",StatusValue);
// Hear I am getting value of rating..in StatusValue..
int status=[StatusValue intValue];
if(status<=3)
{
commenttxtview.hidden=NO;
}
else{
commenttxtview.hidden=YES;
}
}
How can I get label and textview value in viewcontroller and I want to set rate view value to rate view after reload table.
Hear in the Image i am getting five star and If I click on less then 3 star it should have to write comment.I am taking rate value in the label.How can I get both label and textvalue in view controller.Please tell me to update question if you want more data.Thanks in Advance!
So write this in your CustomTableViewCell.h
#property(nonatomic,assign)NSInteger selectedRating;
everytime when the rating is updated in the Cell, you have to change the value of this variable.
In the viewController it depends on when you want to get the value of this cell. For example in this method:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
CustomTableViewCell *yourCell = (CustomerTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
NSLog(#"%lu",yourCell.selectedRating);
}
Let me know if this was helpful!
Another way without a variable is to read the NSString in the statusLabel and change the string to a NSInteger variable...
If you are using your delegate...
Then implement the delegate RateViewDelegatein the viewController. The delegate is called in the class to which it is assigned...
Try this
You have to add the #property (nonatomic, weak) NSObject<RateViewDelegate>* delegate;
to the header file of your CustomTableViewCell.h in the method
-(UITableViewCell) cellForRowAtIndexPath....
you have to assign the delegate like this
cell.delegate = self;
Now modify your cell delegate method to this
- (void)rateView:(RateView *)rateView ratingDidChange:(int)rating {
self.statusLabel.text = [NSString stringWithFormat:#"%d", rating];
NSLog(#"Rating value =%#",self.statusLabel.text);
StatusValue=statusLabel.text;
NSLog(#"Status Value String =%#",StatusValue);
// Hear I am getting value of rating..in StatusValue..
int status=[StatusValue intValue];
if(status<=3)
{
commenttxtview.hidden=NO;
}
else{
commenttxtview.hidden=YES;
}
if([self.delegate respondsToSelector:#selector(rateView:ratingDidChange:)]){
[self.delegate rateView:rateView ratingDidChange:rating];
}
}

Reload UIScrollView by tapping a UIButton

Let me explain my project first. I have some data in my SQLIte DB table called "note".
In "note" table I have these fields: id, noteToken, note.
What I am doing here is load all the note in an NSMUtableArray from that table. And create UIButton according to that array content number and add those buttons in a UIScrollView as subView. The number of buttons and width of scrollview generate auto according to the number of content of that array. Now, when some one tap one of those Buttons, it will bring him to a next viewController and show him the corresponding note details in that viewController.
I do the same thing with another NSMUtableArray, but these time it read all the id from the "note" table. It equally generate new delete button in the same UIScrollView. But if some one tap on these delete button it will delete that particular note from the table "note" of SQLIte DB. AND RELOAD THE UIScrollView. All are done except the RELOAD THE UIScrollView part. This is what I want. I tried with all exist solution but don't know why it's not working.
Here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.noteToken = [NSString stringWithFormat:#"%#%#", fairId, exibitorId];
scrollViewNoteWidth = 100;
[scrollViewNote setScrollEnabled:YES];
[scrollViewNote setContentSize:CGSizeMake((noteButtonWidth * countNoteButtonArray) + scrollViewNoteWidth, 100)];
sqLite = [[SQLite alloc] init];
[self.sqLite callDataBaseAndNoteTableMethods];
self.noteButtonArrayy = [[NSMutableArray alloc] init];
noteButtonArrayy = [self.sqLite returnDataFromNoteTable:noteToken];
[self LoadNoteButtonAndDeleteButton:noteButtonArrayy];
}
//////////////*----------------------- Note Section (Down) -----------------------*//////////////
-(void) LoadNoteButtonAndDeleteButton:(NSMutableArray *) noteButtonArray
{
sQLiteClass = [[SQLiteClass alloc] init];
noteButtonArrayToShowNoteButton = [[NSMutableArray alloc] init];
/*--------------- Load the noteButton & pass note (Down)---------------*/
for (int i = 0; i < [noteButtonArray count]; i++)
{
sQLiteClass = [noteButtonArray objectAtIndex:i];
// NSString *ids = [NSString stringWithFormat:#"%d", sQLiteClass.idNum];
NSString *nt = sQLiteClass.note;
[noteButtonArrayToShowNoteButton addObject:nt];
}
[self ShowNoteButtonMethod:noteButtonArrayToShowNoteButton];
/*--------------- Load the noteButton & pass note (Up)---------------*/
/*--------------- Load the deleteButton & pass id (Down)---------------*/
noteButtonArrayToDeleteNoteButton = [[NSMutableArray alloc] init];
for (int i = 0; i < [noteButtonArray count]; i++)
{
sQLiteClass = [noteButtonArray objectAtIndex:i];
// Convert int into NSString
NSString *ids = [NSString stringWithFormat:#"%d", sQLiteClass.idNum];
[noteButtonArrayToDeleteNoteButton addObject:ids];
}
[self ShowNoteDeleteButtonMethod:noteButtonArrayToDeleteNoteButton];
/*--------------- Load the deleteButton & pass id (Down)---------------*/
}
-(void) ShowNoteButtonMethod:(NSMutableArray *) btnarray
{
countNoteButtonArray = [btnarray count];
// For note button
noteButtonWidth = 60;
noteButtonXposition = 8;
for (NSString *urls in btnarray)
{
noteButtonXposition = [self addNoteButton:noteButtonXposition AndURL:urls];
}
}
-(int) addNoteButton:(int) xposition AndURL:(NSString *) urls
{
noteButton =[ButtonClass buttonWithType:UIButtonTypeCustom];
noteButton.frame = CGRectMake(noteButtonXposition, 8.0, noteButtonWidth, 60.0);
[noteButton setImage:[UIImage imageNamed:#"note.png"] forState:UIControlStateNormal];
[noteButton addTarget:self action:#selector(tapOnNoteButton:) forControlEvents:UIControlEventTouchUpInside];
[noteButton setUrl:urls];
noteButton.backgroundColor = [UIColor clearColor];
[self.scrollViewNote addSubview:noteButton];
noteButtonXposition = noteButtonXposition + noteButtonWidth + 18;
return noteButtonXposition;
}
-(void)tapOnNoteButton:(ButtonClass*)sender
{
urlNote = sender.url;
[self performSegueWithIdentifier:#"goToNoteDetailsViewController" sender:urlNote];
}
-(void) ShowNoteDeleteButtonMethod:(NSMutableArray *) btnarray
{
countNoteButtonArray = [btnarray count];
// For delete button
deleteNoteButtonWidth = 14;
deleteNoteButtonXposition = 31;
for (NSString *idNumber in btnarray)
{
deleteNoteButtonXposition = [self addDeleteButton:deleteNoteButtonXposition AndURL:idNumber];
}
}
-(int) addDeleteButton:(int) xposition AndURL:(NSString *) idNumber
{
deleteNoteButton =[ButtonClass buttonWithType:UIButtonTypeCustom];
deleteNoteButton.frame = CGRectMake(deleteNoteButtonXposition, 74.0, deleteNoteButtonWidth, 20.0);
[deleteNoteButton setImage:[UIImage imageNamed:#"delete.png"] forState:UIControlStateNormal];
[deleteNoteButton addTarget:self action:#selector(tapOnDeleteButton:) forControlEvents:UIControlEventTouchUpInside];
[deleteNoteButton setIdNum:idNumber];
deleteNoteButton.backgroundColor = [UIColor clearColor];
[self.scrollViewNote addSubview:deleteNoteButton];
deleteNoteButtonXposition = deleteNoteButtonXposition + deleteNoteButtonWidth + 65;
return deleteNoteButtonXposition;
}
-(void)tapOnDeleteButton:(ButtonClass*)sender
{
idNumb = sender.idNum;
[self.sqLite deleteData:[NSString stringWithFormat:#"DELETE FROM note WHERE id IS '%#'", idNumb]];
// NSLog(#"idNumb %#", idNumb);
//[self.view setNeedsDisplay];
//[self.view setNeedsLayout];
//[self LoadNoteButtonAndDeleteButton];
//[self viewDidLoad];
// if ([self isViewLoaded])
// {
// //self.view = Nil;
// //[self viewDidLoad];
// [self LoadNoteButtonAndDeleteButton];
// }
}
//////////////*----------------------- Note Section (Up) -----------------------*//////////////
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"goToNoteDetailsViewController"])
{
NoteDetailsViewController *noteDetailsViewController = [segue destinationViewController];
[noteDetailsViewController setUrl:sender];
}
}
Here's the screen shot:
Here we can feel the difference between UIScrollView and UICollectionView, however UICollectionView is made up of UIScrollView, UICollectionView can be reload and adjust its content accordingly, where UIScrollView can't.
Ok, now in your case, you've to reload (refresh) your scroll view, which is not possible as we can with UICollectionView or UITableView.
You've two options,
Best option (little tough) : replace UIScrollView with UICollectionView - will take some of your time, but better for reducing code complexity and good performance of your app.
Poor option (easy) : Stay as it with UIScrollView - when you want to reload, delete each subview from it, and then again show and load everything. Highly not recommended.
IMHO, you should go with best option.

Trying to switch specific UILabel text in list

I have a list of data coming from a database and one of the columns is a date field. Inside that date field I have the date and time. To save room, I have a tap feature to switch between the date and time each time the user touches that uilabel. My issue is trying to know which uilabel the user touched. I have each uilabel with it's own tag incrementing by 1, but I'm confused on how to tell my function which label got pressed.
This is inside a for loop:
_short_time = [date substringFromIndex:range.location + 2];
_short_date = [date substringWithRange:NSMakeRange(0, range.location)];
_dateSwitch = [[UILabel alloc] initWithFrame:CGRectMake(7, 9, 75, 20)];
_dateSwitch.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
_dateSwitch.text = _short_date;
_dateSwitch.tag = i + 1;
_dateSwitch.textAlignment = NSTextAlignmentCenter;
[_dateSwitch setFont:[UIFont systemFontOfSize:13]];
UITapGestureRecognizer *gSwap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(switchDateTime:)];
This is the function being called "switchDateTime":
- (void) switchDateTime: (UITapGestureRecognizer *) sender
{
if (state == 1) {
if (_dateSwitch.tag == _fId) {
[_dateSwitch setText:_short_date];
state = FALSE;
}
} else {
[_dateSwitch setText:_short_time];
state = TRUE;
}
}
You have to add your gesture recognizer on your label like this:
[_dateSwitch addGestureRecognizer:gSwap];
Then on your method to identify which view the gesture recognizer is attached to:
UILabel *tappedLabel = (UILabel *)sender.view;

Calling action in TableView.m from customCell button

I have a UIViewController with a tableView in it with CustomCells, the CustomCell load a PLAY Button for some of the cells, this button are generated within the CustomCell.m
- (UIButton *)videoButton {
if (!videoButton) {
videoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
videoButton.frame = CGRectMake(120, 319, 50, 30);
[videoButton setTitle:#"Play" forState:UIControlStateNormal];
[videoButton addTarget:self action:#selector(PlayClicked:) forControlEvents:UIControlEventTouchUpInside];
videoButton.backgroundColor= [UIColor clearColor];
[self.contentView addSubview:videoButton];
}
playIMG.hidden = false;
return videoButton;
}
- (IBAction)PlayClicked:(id)sender {
TableView *tvvc = [[TableView alloc] init];
[tvvc PlayBtnClicked:[NSString stringWithFormat:#"%d", [sender tag]]];
}
in my TableView.m
- (IBAction)PlayBtnClicked:(id)sender {
NSString *tag = [NSString stringWithFormat:#"%#", sender]; //OK
int tagNumber = [tag intValue]; //OK
NSString *Media = [arrayID objectAtIndex:tagNumber]; //Not Getting Result !
NSLog(#"%#", arrayID); //Array is empty when logging it from this action
}
arrayID is NSMutableArray
arrayID = [[NSMutableArray alloc] init];
[arrayID addObject#"123"];
[arrayID addObject#"321"];
[arrayID addObject#"231"];
soo i checked the array by adding an action button in my TableView to log the array and its not empty.
how can i fix the empty array which is actually not empty ?
I solved the problem in much easier way than the delegate thing
removed
[videoButton addTarget:self action:#selector(PlayClicked:) forControlEvents:UIControlEventTouchUpInside];
and the action in the custom cell .m file
- (IBAction)PlayClicked:(id)sender {
TableView *tvvc = [[TableView alloc] init];
[tvvc PlayBtnClicked:[NSString stringWithFormat:#"%d", [sender tag]]];
}
in the tableView.m i added edited the action i want to link to this
- (IBAction)PlayBtnClicked:(UIButton*)button {
NSLog(#"Button Clicked Tag: %d", button.tag);
}
and in the cellForRowAtIndexPath method i added the action to the button in the custom cell
if ([MediaType isEqualToString:#"video"]) {
cell.videoButton.hidden = NO;
cell.videoButton.tag = indexPath.row;
[cell.videoButton addTarget:self action:#selector(PlayBtnClicked:) forControlEvents:UIControlEventTouchUpInside];//here linking the action to the button
cell.playIMG.hidden = NO;
}
now everything is working very well :)
The array isn't your problem - you're breaking the model-view-controller nature of the table view controller and its cells. If you want a control in the cell to call a method in the table view controller, make the table view controller the delegate of the cell, and call the delegate method from the cell's button.
If the code you've posted is correct, then you're creating a new table view instance in the PlayClicked method, which is definitely not the way to do it.
As a minor stylistic point, the Cocoa convention of method naming is camelCase, with a lower-case initial letter.

I want to put Marquee Label with different label text color

I want to put Marquee Label in UITableView cell but with costomized like label text is different color
I am using MarqueeLabel Classes and I am able to display that Marquee Label on UITableViewCell and it is perfectly work.
I also tried for NSAttributedString but MarqueeLabel Does not support different color of label text
If anybody has answer then please give me
Thanks.
Here is my code
[cell.contentView addSubview:[self createMarqueeLabelWithIndex:indexPath.row]];
[cell.textLabel setTextColor:[UIColor redColor] range:NSMakeRange(4, 3)];
-(MarqueeLabel *)createMarqueeLabelWithIndex:(int)index
{
MarqueeLabel *continuousLabel2 = [[MarqueeLabel alloc] initWithFrame:CGRectMake(10,0,300,30) rate:50.0f andFadeLength:10.0f];
continuousLabel2.marqueeType = MLContinuous;
continuousLabel2.continuousMarqueeSeparator = #"";
continuousLabel2.animationCurve = UIViewAnimationOptionCurveLinear;
continuousLabel2.numberOfLines = 1;
continuousLabel2.opaque = NO;
continuousLabel2.enabled = YES;
continuousLabel2.shadowOffset = CGSizeMake(0.0, -1.0);
continuousLabel2.textAlignment = UITextAlignmentLeft;
continuousLabel2.backgroundColor = [UIColor clearColor];
continuousLabel2.font = [UIFont fontWithName:#"Helvetica-Bold" size:17.000];
NSString *strText = [[arrTicker objectAtIndex:index] objectForKey:#"text"];
NSString *strTime = [[arrTicker objectAtIndex:index] objectForKey:#"time"];
NSString *strUser = [[arrTicker objectAtIndex:index] objectForKey:#"userid"];
NSString *strTemp = [NSString stringWithFormat:#"%# %# %# ",strText,strTime,strUser];
continuousLabel2.text = [NSString stringWithFormat:#"%#",strTemp];
return continuousLabel2;
}
in your cellforrowatindexpath create uilabel and assign your marque label than uilabel's text set to attributed string and than convert uilabel to marque label and than add sub view to your cell.
Hope this will be helpful for you.
Thanks.
Not the best answer but rather a dirty hack.
After quick investigation I've just added [self setTextColor:[super textColor]]; to forwardPropertiesToSubLabel
- (void)forwardPropertiesToSubLabel {
// Since we're a UILabel, we actually do implement all of UILabel's properties.
// We don't care about these values, we just want to forward them on to our sublabel.
NSArray *properties = #[#"baselineAdjustment", #"enabled", #"font", #"highlighted", #"highlightedTextColor", #"minimumFontSize", #"shadowColor", #"shadowOffset", #"textAlignment", #"textColor", #"userInteractionEnabled", #"text", #"adjustsFontSizeToFitWidth", #"lineBreakMode", #"numberOfLines", #"backgroundColor"];
for (NSString *property in properties) {
id val = [super valueForKey:property];
[self.subLabel setValue:val forKey:property];
}
[self setText:[super text]];
[self setFont:[super font]];
[self setTextColor:[super textColor]];
}
Now I can change label color through storyboard editor
NB: As you can see I use plain text. For attributed text hack does not work.

Resources