I try all answer to set tableview cell properly but no any answer work for me, When I scroll tableview only after scrolling tableview dynamic cell is display proper, I have to display multiple type data so that I am using multiple section now on first section I have to display one questions detail data so that I do following code.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if (indexPath.section == 0) {
CGFloat estimatedHeight = 150;
static NSString *cellIdentifier = #"QuestionDetailCell";
quesDetailCell = (QuestionDetailCell *)[tableView dequeueReusableCellWithIdentifier:
cellIdentifier];
if (quesDetailCell == nil) {
quesDetailCell = [[QuestionDetailCell alloc]initWithStyle:
UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
/*Question Title*/
quesDetailCell.lblQuestionTitle.text = [dictionary valueForKey:#"title"];
CGFloat HeightForQuestionTitle = [self getLabelHeight:quesDetailCell.lblQuestionTitle];
/*Question*/
NSRange r;
NSString *s = [NSString stringWithFormat:#"%#",[dictionary valueForKey:#"question"]];
while ((r = [s rangeOfString:#"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:#""];
quesDetailCell.questionlbl.text =s;
CGFloat HeightForQuestion = [self getLabelHeight:quesDetailCell.questionlbl];
/*By User Name*/
NSString *namestr=[NSString stringWithFormat:#"By %# %#",[dictionary objectForKey:#"firstname"],[dictionary objectForKey:#"lastname"]];
quesDetailCell.namelbl.text =namestr;
CGFloat HeightForNamelbl = [self getLabelHeight:quesDetailCell.namelbl];
/*Category*/
quesDetailCell.engineeringlbl.text =[NSString stringWithFormat:#"%#",[dictionary objectForKey:#"category_name"]];
CGFloat HeightForCategory = [self getLabelHeight:quesDetailCell.engineeringlbl];
CGFloat maxHeight = HeightForNamelbl > HeightForCategory ? HeightForNamelbl : HeightForCategory;
CGFloat lblTimeHeight = quesDetailCell.timelbl.frame.size.height;
CGFloat totalHeightOfCell = 8 + HeightForQuestionTitle + 8 + HeightForQuestion + 8 + maxHeight + 8 + lblTimeHeight + quesDetailCell.vwSubButtons.frame.size.height;
if (estimatedHeight < totalHeightOfCell) {
return totalHeightOfCell;
}else{
return estimatedHeight;
}
}else if (indexPath.section == 1){
return 0;
}
else{
return 105;
}
}else{
return 154;
}
}
and for display cell I am doing this,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath{
static NSString *cellIdentifier = #"QuestionDetailCell";
if (indexPath.section==0) {
quesDetailCell = (QuestionDetailCell *)[tableView dequeueReusableCellWithIdentifier:
cellIdentifier];
if (quesDetailCell == nil) {
quesDetailCell = [[QuestionDetailCell alloc]initWithStyle:
UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
/*set User Profile*/
quesDetailCell.profileimg.layer.cornerRadius = quesDetailCell.profileimg.frame.size.height /3;
quesDetailCell.profileimg.layer.masksToBounds = YES;
quesDetailCell.profileimg.layer.borderWidth = 0;
NSString *imagestr=[dictionary objectForKey:#"profilepic"];
[quesDetailCell.profileimg sd_setImageWithURL:[NSURL URLWithString:imagestr]
placeholderImage:[UIImage imageNamed:#"ic_my_colonities_details_2_profile.png"]];
quesDetailCell.btnQuestionDetailProfile.tag = indexPath.row;
[quesDetailCell.btnQuestionDetailProfile addTarget:self action:#selector(mainprofilebtnpress:) forControlEvents:UIControlEventTouchUpInside];
/*calculate height of Question Title*/
quesDetailCell.lblQuestionTitle.text = [dictionary valueForKey:#"title"];
CGFloat HeightForQuestionTitle = [self getLabelHeight:quesDetailCell.lblQuestionTitle];
[quesDetailCell.lblQuestionTitle sizeToFit];
quesDetailCell.lblQuestionTitle.numberOfLines = 0;
/*set Question Title*/
CGFloat questionTitleXPoint = quesDetailCell.profileimg.frame.size.width + 8;
quesDetailCell.lblQuestionTitle.frame = CGRectMake(quesDetailCell.lblQuestionTitle.frame.origin.x, quesDetailCell.lblQuestionTitle.frame.origin.y, quesDetailCell.lblQuestionTitle.frame.size.width, HeightForQuestionTitle);
quesDetailCell.imgQuestionIcon.frame = CGRectMake( quesDetailCell.imgQuestionIcon.frame.origin.x, quesDetailCell.imgQuestionIcon.frame.origin.y, quesDetailCell.imgQuestionIcon.frame.size.width, quesDetailCell.imgQuestionIcon.frame.size.height);
quesDetailCell.questionlbl.frame = CGRectMake( quesDetailCell.questionlbl.frame.origin.x, quesDetailCell.questionlbl.frame.origin.y, quesDetailCell.questionlbl.frame.size.width, quesDetailCell.questionlbl.frame.size.height);
quesDetailCell.namelbl.frame = CGRectMake(quesDetailCell.namelbl.frame.origin.x, quesDetailCell.namelbl.frame.origin.y, quesDetailCell.namelbl.frame.size.width, quesDetailCell.namelbl.frame.size.height);
quesDetailCell.engineeringlbl.frame = CGRectMake(quesDetailCell.engineeringlbl.frame.origin.x, quesDetailCell.engineeringlbl.frame.origin.y, quesDetailCell.engineeringlbl.frame.size.width, quesDetailCell.engineeringlbl.frame.size.height);
quesDetailCell.timelbl.frame = CGRectMake(quesDetailCell.timelbl.frame.origin.x, quesDetailCell.timelbl.frame.origin.y, quesDetailCell.timelbl.frame.size.width, quesDetailCell.timelbl.frame.size.height);
/*Question*/
NSRange r;
NSString *s = [NSString stringWithFormat:#"%#",[dictionary valueForKey:#"question"]];
while ((r = [s rangeOfString:#"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:#""];
quesDetailCell.questionlbl.text =s;
CGFloat HeightForQuestion = [self getLabelHeight:quesDetailCell.questionlbl];
[quesDetailCell.questionlbl sizeToFit];
quesDetailCell.questionlbl.numberOfLines = 0;
/*questionTitleXPoint = question label x possition*/
quesDetailCell.imgQuestionIcon.frame = CGRectMake(questionTitleXPoint, quesDetailCell.imgQuestionIcon.frame.origin.y, 12, 12);
quesDetailCell.questionlbl.frame = CGRectMake(quesDetailCell.questionlbl.frame.origin.x, quesDetailCell.lblQuestionTitle.frame.origin.y + HeightForQuestionTitle + 4, quesDetailCell.questionlbl.frame.size.width, HeightForQuestion);
quesDetailCell.namelbl.frame = CGRectMake(quesDetailCell.namelbl.frame.origin.x, quesDetailCell.namelbl.frame.origin.y, quesDetailCell.namelbl.frame.size.width, quesDetailCell.namelbl.frame.size.height);
quesDetailCell.engineeringlbl.frame = CGRectMake(quesDetailCell.engineeringlbl.frame.origin.x, quesDetailCell.engineeringlbl.frame.origin.y, quesDetailCell.engineeringlbl.frame.size.width, quesDetailCell.engineeringlbl.frame.size.height);
quesDetailCell.timelbl.frame = CGRectMake(quesDetailCell.timelbl.frame.origin.x, quesDetailCell.timelbl.frame.origin.y, quesDetailCell.timelbl.frame.size.width, quesDetailCell.timelbl.frame.size.height);
/*By User Name*/
NSString *namestr=[NSString stringWithFormat:#"By %# %#",[dictionary objectForKey:#"firstname"],[dictionary objectForKey:#"lastname"]];
quesDetailCell.namelbl.text =namestr;
CGFloat HeightForNamelbl = [self getLabelHeight:quesDetailCell.namelbl];
[quesDetailCell.namelbl sizeToFit];
quesDetailCell.namelbl.numberOfLines = 0;
/*Category*/
quesDetailCell.engineeringlbl.text =[NSString stringWithFormat:#"%#",[dictionary objectForKey:#"category_name"]];
CGFloat HeightForCategory = [self getLabelHeight:quesDetailCell.engineeringlbl];
[quesDetailCell.engineeringlbl sizeToFit];
quesDetailCell.engineeringlbl.numberOfLines = 0;
quesDetailCell.namelbl.frame = CGRectMake(quesDetailCell.namelbl.frame.origin.x, quesDetailCell.questionlbl.frame.origin.y + HeightForQuestion + 4 , quesDetailCell.namelbl.frame.size.width, HeightForNamelbl);
quesDetailCell.engineeringlbl.frame =
CGRectMake(quesDetailCell.engineeringlbl.frame.origin.x,
quesDetailCell.questionlbl.frame.origin.y + HeightForQuestion + 4,
quesDetailCell.engineeringlbl.frame.size.width,
HeightForCategory);
CGFloat attachmentlblXPoint = quesDetailCell.engineeringlbl.frame.origin.x - 8 - quesDetailCell.attachmentlbl.frame.size.width;
CGFloat attachmentklblYPoint = quesDetailCell.engineeringlbl.frame.origin.y;
quesDetailCell.attachmentlbl.frame = CGRectMake(attachmentlblXPoint, attachmentklblYPoint - 4 , quesDetailCell.attachmentlbl.frame.size.width, quesDetailCell.attachmentlbl.frame.size.height);
CGFloat btnAttachmentXPoint = attachmentlblXPoint - 4 - quesDetailCell.btnAttachment.frame.size.width ;
quesDetailCell.btnAttachment.frame = CGRectMake(btnAttachmentXPoint, attachmentklblYPoint, quesDetailCell.btnAttachment.frame.size.width, quesDetailCell.btnAttachment.frame.size.height);
quesDetailCell.timelbl.frame = CGRectMake(quesDetailCell.timelbl.frame.origin.x, quesDetailCell.engineeringlbl.frame.origin.y + HeightForCategory + 4, quesDetailCell.timelbl.frame.size.width, quesDetailCell.timelbl.frame.size.height);
CGFloat timeIconXPoint = quesDetailCell.timelbl.frame.origin.x - 4 - quesDetailCell.imgQuestionTimeIcon.frame.size.width;
quesDetailCell.imgQuestionTimeIcon.frame = CGRectMake(timeIconXPoint, quesDetailCell.timelbl.frame.origin.y, quesDetailCell.imgQuestionTimeIcon.frame.size.width,quesDetailCell.imgQuestionTimeIcon.frame.size.height);
/*set VWSubQuestion*/
quesDetailCell.vwSubButtons.frame = CGRectMake(quesDetailCell.vwSubButtons.frame.origin.x, quesDetailCell.imgQuestionTimeIcon.frame.origin.y + quesDetailCell.imgQuestionTimeIcon.frame.size.height + 8 , quesDetailCell.vwSubButtons.frame.size.width, quesDetailCell.vwSubButtons.frame.size.height);
return quesDetailCell;
}
The initial appearance look like this When First load tableview it look like this
After scrolling down then up again:
After Scroll tableview cell look like this
Please help me.
Related
I have tableviews in my storyboard and it is working till Xcode 7.3, After Updating Xcode to 8, imageviews that are added in tableviewcell are not render first time until you scroll OR explicitly call reloadData. Imageviews are added from storyboard.
After scrolling
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ALContactCell *contactCell;
switch (indexPath.section)
{
case 0:
{
//Cell for group button....
contactCell = (ALContactCell *)[tableView dequeueReusableCellWithIdentifier:#"groupCell"];
//Add group button.....
UIButton *newBtn = (UIButton*)[contactCell viewWithTag:101];
[newBtn addTarget:self action:#selector(createGroup:) forControlEvents:UIControlEventTouchUpInside];
newBtn.userInteractionEnabled = YES;
}break;
case 1:
{
//Add rest of messageList
contactCell = (ALContactCell *)[tableView dequeueReusableCellWithIdentifier:#"ContactCell"];
[contactCell.mUserNameLabel setFont:[UIFont fontWithName:[ALApplozicSettings getFontFace] size:USER_NAME_LABEL_SIZE]];
[contactCell.mMessageLabel setFont:[UIFont fontWithName:[ALApplozicSettings getFontFace] size:MESSAGE_LABEL_SIZE]];
[contactCell.mTimeLabel setFont:[UIFont fontWithName:[ALApplozicSettings getFontFace] size:TIME_LABEL_SIZE]];
[contactCell.imageNameLabel setFont:[UIFont fontWithName:[ALApplozicSettings getFontFace] size:IMAGE_NAME_LABEL_SIZE]];
contactCell.unreadCountLabel.backgroundColor = [ALApplozicSettings getUnreadCountLabelBGColor];
contactCell.unreadCountLabel.layer.cornerRadius = contactCell.unreadCountLabel.frame.size.width/2;
contactCell.unreadCountLabel.layer.masksToBounds = YES;
//contactCell.mUserImageView.hidden = NO;
contactCell.mUserImageView.layer.cornerRadius = contactCell.mUserImageView.frame.size.width/2;
contactCell.mUserImageView.layer.masksToBounds = YES;
[contactCell.onlineImageMarker setBackgroundColor:[UIColor clearColor]];
UILabel* nameIcon = (UILabel*)[contactCell viewWithTag:102];
nameIcon.textColor = [UIColor whiteColor];
ALMessage *message = (ALMessage *)self.mContactsMessageListArray[indexPath.row];
ALContactDBService *contactDBService = [[ALContactDBService alloc] init];
ALContact *alContact = [contactDBService loadContactByKey:#"userId" value: message.to];
ALChannelDBService * channelDBService =[[ALChannelDBService alloc] init];
ALChannel * alChannel = [channelDBService loadChannelByKey:message.groupId];
if([message.groupId intValue])
{
ALChannelService *channelService = [[ALChannelService alloc] init];
[channelService getChannelInformation:message.groupId orClientChannelKey:nil withCompletion:^(ALChannel *alChannel)
{
contactCell.mUserNameLabel.text = [alChannel name];
contactCell.onlineImageMarker.hidden=YES;
}];
}
else
{
contactCell.mUserNameLabel.text = [alContact getDisplayName];
}
contactCell.mMessageLabel.text = message.message;
contactCell.mMessageLabel.hidden = NO;
if ([message.type integerValue] == [FORWARD_STATUS integerValue])
contactCell.mLastMessageStatusImageView.image = [ALUtilityClass getImageFromFramworkBundle:#"mobicom_social_forward.png"];
else if ([message.type integerValue] == [REPLIED_STATUS integerValue])
contactCell.mLastMessageStatusImageView.image = [ALUtilityClass getImageFromFramworkBundle:#"mobicom_social_reply.png"];
BOOL isToday = [ALUtilityClass isToday:[NSDate dateWithTimeIntervalSince1970:[message.createdAtTime doubleValue]/1000]];
contactCell.mTimeLabel.text = [message getCreatedAtTime:isToday];
[self displayAttachmentMediaType:message andContactCell:contactCell];
// here for msg dashboard profile pic
[nameIcon setText:[ALColorUtility getAlphabetForProfileImage:[alContact getDisplayName]]];
if([message getGroupId])
{
[contactCell.onlineImageMarker setHidden:YES];
}
else if(alContact.connected && [ALApplozicSettings getVisibilityForOnlineIndicator])
{
[contactCell.onlineImageMarker setHidden:NO];
}
else
{
[contactCell.onlineImageMarker setHidden:YES];
}
if(alContact.block || alContact.blockBy)
{
[contactCell.onlineImageMarker setHidden:YES];
}
BOOL zeroContactCount = (alContact.unreadCount.intValue == 0 ? true:false);
BOOL zeroChannelCount = (alChannel.unreadCount.intValue == 0 ? true:false);
if(zeroChannelCount || zeroContactCount)
{
contactCell.unreadCountLabel.text = #"";
[contactCell.unreadCountLabel setHidden:YES];
}
if(!zeroContactCount && [alContact userId] && (message.groupId.intValue == 0 || message.groupId == NULL)){
[contactCell.unreadCountLabel setHidden:NO];
contactCell.unreadCountLabel.text=[NSString stringWithFormat:#"%i",alContact.unreadCount.intValue];
}
else if(!zeroChannelCount && [message.groupId intValue]){
[contactCell.unreadCountLabel setHidden:NO];
contactCell.unreadCountLabel.text = [NSString stringWithFormat:#"%i",alChannel.unreadCount.intValue];
}
contactCell.mUserImageView.backgroundColor = [UIColor whiteColor];
if([message.groupId intValue])
{
[contactCell.mUserImageView setImage:[ALUtilityClass getImageFromFramworkBundle:#"applozic_group_icon.png"]];
NSURL * imageUrl = [NSURL URLWithString:alChannel.channelImageURL];
if(imageUrl)
{
[contactCell.mUserImageView sd_setImageWithURL:imageUrl];
}
nameIcon.hidden = YES;
}
else if(alContact.contactImageUrl)
{
NSURL * theUrl1 = [NSURL URLWithString:alContact.contactImageUrl];
[contactCell.mUserImageView sd_setImageWithURL:theUrl1];
nameIcon.hidden = YES;
}
else
{
nameIcon.hidden = NO;
[contactCell.mUserImageView sd_setImageWithURL:[NSURL URLWithString:#""]];
contactCell.mUserImageView.backgroundColor = [ALColorUtility getColorForAlphabet:[alContact getDisplayName]];
}
}break;
default:
break;
}
return contactCell;
}
After long hit and trials it worked after updating
dispatch_async(dispatch_get_main_queue(), ^{
contactCell.mUserImageView.layer.cornerRadius = contactCell.mUserImageView.frame.size.width/2;
contactCell.mUserImageView.layer.masksToBounds = YES;
});
OR
you can use context graphics to get circular image
But still need a prior solution
I am new in objective c and now i try to build game like What's the word and i have some problems with targets coordinates and button passing into targets. I create a -(void)dealRandomWord here I am take randome a word from plist and output all my subview on screen. I call it from viewDidLoad: [self dealRandomWord].
And here is my problem:
#pragma mark Targets
_targets = [NSMutableArray arrayWithCapacity:word1len];
for (NSInteger i = 0; i < word1len; i++) {
NSString *letter = [word1 substringWithRange:NSMakeRange(i, 1)];
TargetView *target = [[TargetView alloc] initWithLetter:letter andSideLength: letterSide];
target.center = CGPointMake(xCenterTarget + i * (letterSide + kLetterMargin), placesView.frame.size.height / 2);
[placesView addSubview:target];
NSLog(#"biiitch %#", NSStringFromCGPoint(target.center));
}
In target.center i have the coordinates of targets where i want to move my buttons by click. When i click one of the button it moved but not in the target, it happens because in
-(void)placeForButton:(InputButtonsView*)inputButtonsView atTarget:(TargetView*)targetView {
targetView.center coordinate equal {0,0}
How can i pass coordinates for each of target to my button that it's move to target. Every next button should move to next target.
Here is image: Screenshot
Thanks for any help!!!
Here is my code:
-(void)dealRandomWord {
#pragma mark Level and words init
NSAssert(self.level.words, #"Level not loaded");
// random word from plist
NSInteger randomIndex = arc4random()%[self.level.words count];
NSArray* anaPair = self.level.words[ randomIndex ];
NSString* question = anaPair[0]; // question
NSString* word1 = anaPair[1]; // answer
NSString* word2 = anaPair[2]; // some letters
NSString* helpstr = anaPair[3]; // helper
NSLog(#"qweqweq %# %# %#" , word1 , word2 , helpstr);
NSInteger word1len = [word1 length];
NSInteger word2len = [word2 length];
NSLog(#"phrase1[%li]: %#", (long)word1len, word1);
NSLog(#"phrase2[%li]: %#", (long)word2len, word2);
NSLog(#"question %#", question);
float letterSide = ceilf (kScreenWidth * 0.9 / (float)MAX(word1len, word2len) - kLetterMargin);
float xOffset = (kScreenWidth - (float)MAX(word1len, word2len) * (letterSide + kLetterMargin))/3;
xOffset += letterSide/2;
float yOffset = 1.5* letterSide;
#pragma mark QuestionView init
QuestionView *quv = [[QuestionView alloc] init];
quv.questionLabel.text = question;
[self.view addSubview:quv];
quv.center = CGPointMake(185, 210);
#pragma mark PlacesView init
PlacesView *placesView = [[PlacesView alloc] init];
[self.view addSubview:placesView];
placesView.center = CGPointMake(185, 400);
//Center x position for targets
float xCenterTarget = ((placesView.frame.size.width / 2) - ((word1len / 2) * letterSide ));
#pragma mark LetterView init
LettersView *lettersView = [[LettersView alloc] init];
[self.view addSubview:lettersView];
lettersView.center = CGPointMake(185, 500);
#pragma mark Targets
_targets = [NSMutableArray arrayWithCapacity:word1len];
for (NSInteger i = 0; i < word1len; i++) {
NSString *letter = [word1 substringWithRange:NSMakeRange(i, 1)];
TargetView *target = [[TargetView alloc] initWithLetter:letter andSideLength: letterSide];
target.center = CGPointMake(xCenterTarget + i * (letterSide + kLetterMargin), placesView.frame.size.height / 2);
[placesView addSubview:target];
NSLog(#"coord target init %#", NSStringFromCGPoint(target.center));
}
#pragma mark LettersView init
//init letters list
_letters = [NSMutableArray arrayWithCapacity: word2len];
//create letter
for (NSInteger i=0;i<word2len;i++) {
NSString* letter = [word2 substringWithRange:NSMakeRange(i, 1)];
if (![letter isEqualToString:#" "]) {
InputButtonsView *buttons = [[InputButtonsView alloc] initWithLetter:letter andSideLength:letterSide];
buttons.center = CGPointMake(xOffset + i * (letterSide + kLetterMargin), lettersView.frame.size.height /2); // "/3*4" kScreenHeight/4*3
if (i > 6) {
buttons.center = CGPointMake(- 7 * xOffset + i * (letterSide + kLetterMargin), lettersView.frame.size.height/2 + (letterSide + kLetterMargin)); // "/3*4"
}
buttons.clickDelegate = self;
[lettersView addSubview:buttons];
//[buttons addSubview:buttons];
[_letters addObject: letter];
}
}
}
-(void)inputButtonView:(InputButtonsView *)inputButtonView didPress:(CGPoint)didPress {
TargetView *targetView = nil;
NSLog(#"did press x = %f, y = %f", didPress.x , didPress.y);
for(TargetView *tv in _targets) {
if(CGRectContainsPoint(tv.frame, didPress)){
targetView = tv;
break;
}
}
[self placeForButton:inputButtonView atTarget:targetView];
if (targetView != nil) {
NSLog(#"Kek");
if ([targetView.letter isEqualToString: inputButtonView.letter]) {
[self placeForButton:inputButtonView atTarget:targetView];
}
}
}
-(void)placeForButton:(InputButtonsView*)inputButtonsView atTarget:(TargetView*)targetView {
targetView.isMatched = YES;
inputButtonsView.isMatched = YES;
inputButtonsView.userInteractionEnabled = NO;
CGPoint originButtons = [self.view.superview convertPoint:CGPointZero fromView:inputButtonsView];
CGPoint originTargets = [self.view.superview convertPoint:CGPointZero fromView:targetView];
inputButtonsView.center = originButtons;
targetView.center = originTargets;
NSLog(#"OriginButtons = %# , OriginTargets = %#", NSStringFromCGPoint(originButtons) , NSStringFromCGPoint(originTargets));
inputButtonsView.center = targetView.center;
NSLog(#"TARGETVIEW.center %#", NSStringFromCGPoint(targetView.center));
}
At first view load it shows me properly like this:
Then when I refresh table or pop the view back it messes up like this:
But If I scroll down when it passes off the table it comes back to normal.
I populate the cell like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = #"Cell";
TableCell *cellTable = (TableCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if ([[_itemsOfPath objectAtIndex:indexPath.row] isKindOfClass:[OCFileDto class]] ) {
//Add swipe menu
cellTable.leftUtilityButtons = [self leftButtons];
cellTable.delegate = self;
OCFileDto *itemDto = [_itemsOfPath objectAtIndex:indexPath.row];
[cellTable setSelectionStyle:UITableViewCellSelectionStyleNone];
cellTable.cellName.lineBreakMode = NSLineBreakByTruncatingMiddle;
cellTable.filePath = [itemDto.filePath stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)NSUTF8StringEncoding];
cellTable.fileName = [itemDto.fileName stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)NSUTF8StringEncoding];
if ([itemDto isDirectory]) {
cellTable.cellImg.image = [UIImage imageNamed:#"b_ic_menu_archive.png"];
cellTable.cellType = kCellTypeFolder;
cellTable.cellName.text = [cellTable.fileName substringToIndex:[cellTable.fileName length]-1];
cellTable.timeStamp.text = [self stringLasResponse:itemDto.date];
numberOfFolder++;
} else {
if ([[cellTable.fileName pathExtension] caseInsensitiveCompare:#"pdf"] == NSOrderedSame) {
cellTable.cellImg.image = [UIImage imageNamed:#"file_pdf.png"];
cellTable.cellType = kCellTypeFilePDF;
}else{
if ([[cellTable.fileName pathExtension] caseInsensitiveCompare:#"jpg"] == NSOrderedSame ||
[[cellTable.fileName pathExtension] caseInsensitiveCompare:#"png"] == NSOrderedSame ||
[[cellTable.fileName pathExtension] caseInsensitiveCompare:#"gif"] == NSOrderedSame) {
cellTable.cellImg.image = [UIImage imageNamed:#"file_image.png"];
cellTable.cellType = kCellTypeFilePicture;
}else{
cellTable.cellImg.image = [UIImage imageNamed:#"file.png"];
cellTable.cellType = kCellTypeOtherFile;
}
/*============Check if file on local or not==============*/
NSString *localPath = [NSString stringWithFormat:#"%#/%#",documentPath ,cellTable.fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:localPath] && cellTable.cellType != kCellTypeFolder) {
cellTable.downloadedOverlay.image = [UIImage imageNamed:#"DownloadedOverlay.png"];
/*============Check if file on local or not==============*/
}
}
cellTable.cellName.text = cellTable.fileName;
cellTable.timeStamp.text = [NSString stringWithFormat:#"%#, %#", [self stringLasResponse:itemDto.date], [NSByteCountFormatter stringFromByteCount:itemDto.size countStyle:NSByteCountFormatterCountStyleMemory]];
numberOfFile++;
}
return cellTable;
}else{
// Show File Summary at last Cell
if ([[_itemsOfPath objectAtIndex:indexPath.row] isKindOfClass:[TableViewCellNoBorder class]] ) {
if ([_itemsOfPath count] > 1 ) {
NSString *tableSummary;
if (numberOfFolder == 0) {
tableSummary = [NSString stringWithFormat:#"%d files", numberOfFile];
}else{
if (numberOfFile == 0) {
tableSummary = [NSString stringWithFormat:#"%d folders", numberOfFolder];
}else{
tableSummary = [NSString stringWithFormat:#"%d files, %d folders",numberOfFile,numberOfFolder];
}
}
//Summery cell
TableViewCellNoBorder *lastCell = [_itemsOfPath objectAtIndex:indexPath.row];
lastCell.textLabel.text = tableSummary;
lastCell.textLabel.font = [UIFont systemFontOfSize:9];
lastCell.textLabel.textAlignment = NSTextAlignmentCenter;
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
return lastCell;
}
}
//No file and folder
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
return [_itemsOfPath objectAtIndex:indexPath.row];
}
}
*** That line I use it to add a green arrow.
I debug it and see all the files that will add my green arrow is call properly but when it shows some other cell has that green arrow in it too.
I read around it said some thing about that cell has been dequeue and it loses their state and do something like:
if (cellTable == nil) {
NSLog(#"TEST");
}
But when I Debug it, they weren't called at all.
I don't know how to deal with it. Can anybody give me a suggestion?
Thank you.
EDIT:
Ok, after checking with more detail your code, change:
if ([itemDto isDirectory]) {
cellTable.cellImg.image = [UIImage imageNamed:#"b_ic_menu_archive.png"];
cellTable.cellType = kCellTypeFolder;
cellTable.cellName.text = [cellTable.fileName substringToIndex:[cellTable.fileName length]-1];
cellTable.timeStamp.text = [self stringLasResponse:itemDto.date];
numberOfFolder++;
}
to
if ([itemDto isDirectory]) {
cellTable.cellImg.image = [UIImage imageNamed:#"b_ic_menu_archive.png"];
cellTable.cellType = kCellTypeFolder;
cellTable.cellName.text = [cellTable.fileName substringToIndex:[cellTable.fileName length]-1];
cellTable.timeStamp.text = [self stringLasResponse:itemDto.date];
numberOfFolder++;
cellTable.downloadedOverlay.image = nil;
}
I hope you understand what's going on. When you dequeue a cell, you get it as it was set up last time it was used. You have to clear everything up and set all the elements of the cell to display the new information.
End edit
Add
else {
cellTable.downloadedOverlay.image = nil;
}
to the if clause:
/*============Check if file on local or not==============*/
NSString *localPath = [NSString stringWithFormat:#"%#/%#",documentPath ,cellTable.fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:localPath] && cellTable.cellType != kCellTypeFolder) {
cellTable.downloadedOverlay.image = [UIImage imageNamed:#"DownloadedOverlay.png"];
/*============Check if file on local or not==============*/
}
Final:
/*============Check if file on local or not==============*/
NSString *localPath = [NSString stringWithFormat:#"%#/%#",documentPath ,cellTable.fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:localPath] && cellTable.cellType != kCellTypeFolder) {
cellTable.downloadedOverlay.image = [UIImage imageNamed:#"DownloadedOverlay.png"];
/*============Check if file on local or not==============*/
}
else {
cellTable.downloadedOverlay.image = nil;
}
This way, if you get a dequeued cell that had the image already set, you clear it up.
I had an comments array, witch contains the comment message and the reply message and follow the reply message.want to show all the messages orderly, seems its An infinite loop.
My code is like below:
if (self.commentArray.count > 0) {
//comments
NSDictionary *message = [self.commentArray objectAtIndex:indexPath.row];
if ([FHWServiceManager isValidObject:[message objectForKey:#"UserIcon"]]) {
[cell.photoImageView setImageWithURL:[NSURL URLWithString:[message objectForKey:#"UserIcon"]] placeholderImage:[UIImage imageNamed:#"face_poor"]];
}else {
cell.photoImageView.image = [UIImage imageNamed:#"face_poor"];
}
cell.photoImageView.layer.cornerRadius = 15;
cell.photoImageView.layer.masksToBounds = YES;
cell.nameLabel.text = [message objectForKey:#"Username"];
cell.nameLabel.textColor = UIColorFromRGB(0xbf6327);
cell.contentLabel.text = [message objectForKey:#"Comment"];
cell.timeLabel.text = [DateUtil timePassedDescriptionFor:[DateUtil dateFromRFC3339DateString:[message objectForKey:#"CreateTime"]]];
//follow comment
NSPredicate *predicate = [NSPredicate predicateWithFormat:#"PId == %d",[[message objectForKey:#"Id"] intValue]];
NSArray *tempArray = [self.replyCommentArray filteredArrayUsingPredicate:predicate];
if (tempArray.count > 0) {
UIImageView *triangleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(67, 80, 10, 5)];
triangleImageView.image = [UIImage imageNamed:#"comment_reply_arrow_top"];
[cell.contentView addSubview:triangleImageView];
UIView *followBackView = [[UIView alloc] initWithFrame:CGRectMake(55, 85, 245, tempArray.count * 21 + 10)];
followBackView.backgroundColor = UIColorFromRGB(0xf6f6f6);
followBackView.layer.cornerRadius = 5;
float lastHeight = 0.0;
for (int i = 0; i < tempArray.count; i ++) {
NSDictionary *replyMessage = [tempArray objectAtIndex:i];
NSString *replyStr;
replyStr = [NSString stringWithFormat:#"%#: %#",[replyMessage objectForKey:#"Username"],[replyMessage objectForKey:#"Comment"]];
TTTAttributedLabel *followCommentLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(5, lastHeight + 5, followBackView.frame.size.width, 21)];
// followCommentLabel.numberOfLines = 0;
followCommentLabel.font = [UIFont systemFontOfSize:13];
followCommentLabel.textColor = [UIColor darkGrayColor];
followCommentLabel.backgroundColor = [UIColor clearColor];
[followCommentLabel setText:replyStr afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
NSRange redColorRange = [[mutableAttributedString string] rangeOfString:[NSString stringWithFormat:#"%#:",[replyMessage objectForKey:#"Username"]] options:NSCaseInsensitiveSearch];
// Core Text APIs use C functions without a direct bridge to UIFont. See Apple's "Core Text Programming Guide" to learn how to configure string attributes.
NSDictionary *colorDic = [NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xbf6327),kCTForegroundColorAttributeName, nil];
[mutableAttributedString addAttributes:colorDic range:redColorRange];
return mutableAttributedString;
}];
[followBackView addSubview:followCommentLabel];
UIButton *followButton = [UIButton buttonWithType:UIButtonTypeCustom];
followButton.frame = followCommentLabel.frame;
NSString *identify = [NSString stringWithFormat:#"%d",i];
[followButton setTitle:identify forState:UIControlStateSelected];
followButton.titleLabel.textColor = [UIColor clearColor];
[followButton addTarget:self action:#selector(handleFollowComment:) forControlEvents:UIControlEventTouchUpInside];
followButton.tag = indexPath.row + 10000;
[followBackView addSubview:followButton];
[followBackView bringSubviewToFront:followButton];
// CGSize size = [followCommentLabel.text sizeWithFont:followCommentLabel.font
// constrainedToSize:CGSizeMake(240, 800)
// lineBreakMode:NSLineBreakByWordWrapping];
// followCommentLabel.frame = CGRectMake(5, 0, 418, size.height);
predicate = [NSPredicate predicateWithFormat:#"PId == %d",[[replyMessage objectForKey:#"Id"] intValue]];
NSArray *subTempArray = [self.replyCommentArray filteredArrayUsingPredicate:predicate];
lastHeight += 21;
if (subTempArray.count > 0) {
lastHeight += subTempArray.count * 21;
float height = followBackView.frame.size.height;
height += 21*subTempArray.count;
followBackView.frame = CGRectMake(followBackView.frame.origin.x, followBackView.frame.origin.y, followBackView.frame.size.width, height);
float followLabelHeight = 0.0;
for (int j =0 ; j < subTempArray.count; j ++) {
NSDictionary *ohterMessage = [subTempArray objectAtIndex:j];
replyStr = [NSString stringWithFormat:#"%#reply%#: %#",[ohterMessage objectForKey:#"Username"],[replyMessage objectForKey:#"Username"],[ohterMessage objectForKey:#"Comment"]];
TTTAttributedLabel *subCommentLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(5, followCommentLabel.frame.origin.y + followCommentLabel.frame.size.height + followLabelHeight, followBackView.frame.size.width, 21)];
// subCommentLabel.numberOfLines = 0;
subCommentLabel.font = [UIFont systemFontOfSize:13];
subCommentLabel.textColor = [UIColor darkGrayColor];
subCommentLabel.backgroundColor = [UIColor clearColor];
[subCommentLabel setText:replyStr afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
NSRange redColorRange = [[mutableAttributedString string] rangeOfString:[NSString stringWithFormat:#"%#reply%#:",[ohterMessage objectForKey:#"Username"],[replyMessage objectForKey:#"Username"]] options:NSCaseInsensitiveSearch];
// Core Text APIs use C functions without a direct bridge to UIFont. See Apple's "Core Text Programming Guide" to learn how to configure string attributes.
NSDictionary *colorDic = [NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xbf6327),kCTForegroundColorAttributeName, nil];
[mutableAttributedString addAttributes:colorDic range:redColorRange];
return mutableAttributedString;
}];
[followBackView addSubview:subCommentLabel];
UIButton *subfollowButton = [UIButton buttonWithType:UIButtonTypeCustom];
subfollowButton.frame = subCommentLabel.frame;
NSString *subIdentify = [NSString stringWithFormat:#"%d-%d",i,j];
[subfollowButton setTitle:subIdentify forState:UIControlStateSelected];
subfollowButton.titleLabel.textColor = [UIColor clearColor];
[subfollowButton addTarget:self action:#selector(handleFollowComment:) forControlEvents:UIControlEventTouchUpInside];
subfollowButton.tag = indexPath.row + 10000;
[followBackView addSubview:subfollowButton];
[followBackView bringSubviewToFront:subfollowButton];
// CGSize size = [followCommentLabel.text sizeWithFont:followCommentLabel.font
// constrainedToSize:CGSizeMake(240, 800)
// lineBreakMode:NSLineBreakByWordWrapping];
// followCommentLabel.frame = CGRectMake(5, 0, 418, size.height);
predicate = [NSPredicate predicateWithFormat:#"PId == %d",[[ohterMessage objectForKey:#"Id"] intValue]];
NSArray *subFollowTempArray = [self.replyCommentArray filteredArrayUsingPredicate:predicate];
followLabelHeight += 21;
if (subFollowTempArray.count > 0) {
followLabelHeight += subFollowTempArray.count * 21;
lastHeight += subFollowTempArray.count * 21;
float height = followBackView.frame.size.height;
height += 21*subFollowTempArray.count;
followBackView.frame = CGRectMake(followBackView.frame.origin.x, followBackView.frame.origin.y, followBackView.frame.size.width, height);
for (int k =0 ; k < subFollowTempArray.count; k ++) {
NSDictionary *ohterFollowMessage = [subFollowTempArray objectAtIndex:k];
NSString *replyFollowStr = [NSString stringWithFormat:#"%#reply%#: %#",[ohterFollowMessage objectForKey:#"Username"],[ohterMessage objectForKey:#"Username"],[ohterFollowMessage objectForKey:#"Comment"]];
TTTAttributedLabel *subFollowCommentLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(5, subCommentLabel.frame.origin.y + subCommentLabel.frame.size.height + k * 21, followBackView.frame.size.width, 21)];
// subCommentLabel.numberOfLines = 0;
subFollowCommentLabel.font = [UIFont systemFontOfSize:13];
subFollowCommentLabel.textColor = [UIColor darkGrayColor];
subFollowCommentLabel.backgroundColor = [UIColor clearColor];
[subFollowCommentLabel setText:replyFollowStr afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
NSRange redColorRange = [[mutableAttributedString string] rangeOfString:[NSString stringWithFormat:#"%#reply%#:",[ohterFollowMessage objectForKey:#"Username"],[ohterMessage objectForKey:#"Username"]] options:NSCaseInsensitiveSearch];
// Core Text APIs use C functions without a direct bridge to UIFont. See Apple's "Core Text Programming Guide" to learn how to configure string attributes.
NSDictionary *colorDic = [NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xbf6327),kCTForegroundColorAttributeName, nil];
[mutableAttributedString addAttributes:colorDic range:redColorRange];
return mutableAttributedString;
}];
[followBackView addSubview:subFollowCommentLabel];
}
}
}
}
}
[cell.contentView addSubview:followBackView];
}
Try this, this may not be the exact solution. But you can follow this approach with some minor changes
- (NSArray *) replyforPid:(int) pID {
NSPredicate *predicate = [NSPredicate predicateWithFormat:#"PId == %d",pID];
NSArray *tempArray = [self.replyCommentArray filteredArrayUsingPredicate:predicate];
return tempArray;
}
- (void) addReplyInView:(UIView *) followBackView forPid:(int) pID lastHeight:(float) lastHeight {
NSArray *tempArray = [self replyforPid:pID];
if ([tempArray count] > 0) {
if (lastHeight != 0) {
float height = followBackView.frame.size.height;
height += 21*subTempArray.count;
followBackView.frame = CGRectMake(followBackView.frame.origin.x, followBackView.frame.origin.y, followBackView.frame.size.width, height);
}
for (int i = 0; i < tempArray.count; i ++) {
NSDictionary *replyMessage = [tempArray objectAtIndex:i];
NSString *replyStr;
replyStr = [NSString stringWithFormat:#"%#: %#",[replyMessage objectForKey:#"Username"],[replyMessage objectForKey:#"Comment"]];
TTTAttributedLabel *followCommentLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(5, lastHeight + 5, followBackView.frame.size.width, 21)];
followCommentLabel.font = [UIFont systemFontOfSize:13];
followCommentLabel.textColor = [UIColor darkGrayColor];
followCommentLabel.backgroundColor = [UIColor clearColor];
[followCommentLabel setText:replyStr afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
NSRange redColorRange = [[mutableAttributedString string] rangeOfString:[NSString stringWithFormat:#"%#:",[replyMessage objectForKey:#"Username"]] options:NSCaseInsensitiveSearch];
// Core Text APIs use C functions without a direct bridge to UIFont. See Apple's "Core Text Programming Guide" to learn how to configure string attributes.
NSDictionary *colorDic = [NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xbf6327),kCTForegroundColorAttributeName, nil];
[mutableAttributedString addAttributes:colorDic range:redColorRange];
return mutableAttributedString;
}];
[followBackView addSubview:followCommentLabel];
UIButton *followButton = [UIButton buttonWithType:UIButtonTypeCustom];
followButton.frame = followCommentLabel.frame;
NSString *identify = [NSString stringWithFormat:#"%d",i];
[followButton setTitle:identify forState:UIControlStateSelected];
followButton.titleLabel.textColor = [UIColor clearColor];
[followButton addTarget:self action:#selector(handleFollowComment:) forControlEvents:UIControlEventTouchUpInside];
[followBackView addSubview:followButton];
[followBackView bringSubviewToFront:followButton];
lastHeight += 21;
[self addReplyInView:followBackView forPid:[[replyMessage objectForKey:#"Id"] intValue] lastHeight:lastHeight];
}
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.commentArray.count > 0) {
//comments
NSDictionary *message = [self.commentArray objectAtIndex:indexPath.row];
if ([FHWServiceManager isValidObject:[message objectForKey:#"UserIcon"]]) {
[cell.photoImageView setImageWithURL:[NSURL URLWithString:[message objectForKey:#"UserIcon"]] placeholderImage:[UIImage imageNamed:#"face_poor"]];
}else {
cell.photoImageView.image = [UIImage imageNamed:#"face_poor"];
}
cell.photoImageView.layer.cornerRadius = 15;
cell.photoImageView.layer.masksToBounds = YES;
cell.nameLabel.text = [message objectForKey:#"Username"];
cell.nameLabel.textColor = UIColorFromRGB(0xbf6327);
cell.contentLabel.text = [message objectForKey:#"Comment"];
cell.timeLabel.text = [DateUtil timePassedDescriptionFor:[DateUtil dateFromRFC3339DateString:[message objectForKey:#"CreateTime"]]];
//follow comment
NSArray *tempArray = [self replyforPid:[[message objectForKey:#"Id"] intValue]];
if (tempArray.count > 0) {
UIImageView *triangleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(67, 80, 10, 5)];
triangleImageView.image = [UIImage imageNamed:#"comment_reply_arrow_top"];
[cell.contentView addSubview:triangleImageView];
UIView *followBackView = [[UIView alloc] initWithFrame:CGRectMake(55, 85, 245, tempArray.count * 21 + 10)];
followBackView.backgroundColor = UIColorFromRGB(0xf6f6f6);
followBackView.layer.cornerRadius = 5;
[self addReplyInView:followBackView forPid:[[message objectForKey:#"Id"] intValue] intValue] lastHeight:0.0];
}
}
}
I was looking into implementing hashtag autocomplete with objective-C as shown in the picture
I found it a bit difficult than expected. I'm looking more specific implementation for adding and deleting hashtags. For example, the hashtag should be deleted as a whole at once. I was wondering if anyone has similar experience implemented it and if there's a more efficient way implemented it. Thanks
I ended up writing some functions that I feel is a bit ugly but it works. Maybe there are some more efficient ways to implement it.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//user is a singleton instance
User *user = [User sharedUser];
user.autocompleteTableView.hidden = NO;
int identifiedTagsStringLength = [self.identifiedTagsString length];
int cursorLocation = range.location;
//insert characters
if (range.location >= identifiedTagsStringLength) {
NSString *newSearch =#"";
NSRange newRange;
if(identifiedTagsStringLength != 0) {
newSearch = [urlField.text substringFromIndex:identifiedTagsStringLength];
newRange = NSMakeRange(range.location - identifiedTagsStringLength, 0);
}
else {
newSearch = textField.text;
newRange = range;
}
NSString *substring = [NSString stringWithString:newSearch];
substring = [substring stringByReplacingCharactersInRange:newRange withString:string];
[self searchAutocompleteEntriesWithSubstring:substring];
if (cursorLocation > currentTagsRange) {
currentTagsRange = cursorLocation;
}
}
//delete tags
else {
if ([self.ranges count] != 0 && cursorLocation < currentTagsRange) {
int rangeLength = [self.ranges count];
int toBeRemovedIndex = 0;
for (int i = 0; i< rangeLength; i++) {
if (cursorLocation >= [[self.ranges objectAtIndex:i][0] intValue]
&& cursorLocation <= [[self.ranges objectAtIndex:i][1] intValue]) {
toBeRemovedIndex = i;
}
}
[self.tags removeObjectAtIndex:toBeRemovedIndex];
[self updateRanges];
NSString *outputString = #"";
for (NSString *tag in self.tags) {
outputString = [NSString stringWithFormat:#"%##%# ", outputString,
tag];
}
urlField.text = outputString;
self.identifiedTagsString = urlField.text;
currentTagsRange = [outputString length] - 1;
}
}
return YES;
}
- (void)updateRanges {
self.ranges = [[NSMutableArray alloc] init];
int startIndex = 0;
for (NSString *tag in self.tags) {
startIndex = [self.ranges count] == 0 ? 0 : [[self.ranges lastObject][1] intValue] + 1;
int tagLength = [tag length];
NSArray *range = [NSArray arrayWithObjects:[NSNumber numberWithInt:startIndex], [NSNumber numberWithInt:startIndex + tagLength + 1], nil];
[self.ranges addObject: range];
}
}
#pragma mark UITableViewDataSource methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
if (self.identifiedTagsString == NULL) {
self.identifiedTagsString = #"";
}
[self.tags addObject: selectedCell.textLabel.text];
[self updateRanges];
NSString *output = #"";
for (NSString *tag in self.tags) {
output = [NSString stringWithFormat:#"%##%# ", output, tag];
}
urlField.text = output;
User *user = [User sharedUser];
user.autocompleteTableView.hidden = YES;
self.identifiedTagsString = urlField.text;
currentTagsRange = [urlField.text length];
}