Uitableview cell text got hidden on edit Button - objective-c

When i try to delete any row - while clicking the edit button - the delete button appears and the text on right side truncated from the end.
I want to compress it automatically while delete button appears.

You can try setting the textLabel property attributes to automatically truncate the middle of the string or set a smaller (minimum) font.
[[theCell textLabel] setMinimumFontSize:theSizeYouWant];
or
[[theCell textLabel] setLineBreakMode:UILineBreakModeMiddleTruncation];

Related

UITableView removing checkmark from cell on search

I am using a UITableView to display some items and i have implemented a UISearchBar to this UITableView.
If the user presses the cell, a checkmark appears (accessory type of the cell is changed) and when pressed again the checkmark accessory disappears.
My problem is when the user searches using the search bar, all the checked cells are not checked anymore, no more checked cells at all.
I've been trying to fix this and searching for it for a while but no results ...
Any help ??
Thanks you.
That is because your table view where you put the checkmarks and the table view that you see after you enter something in the search bar is not same. To have the same check marks on the search table view cells, you need to explicitly add the checkmarks.
I can't see the way you are adding and removing check marks. So, in theory, what you need is a way to know which cells have check marks. So, let's assume you have an array of items and a parallel array which holds the 1 or 0 to signal if the items have the check marks when 1 means check marked and 0 means no check mark.
Let's call this parallel array, checkMarkSignalArray. Now, in your cellForRowAtIndexPath method, you can do something like-
if(self.resultSearchController.active){
cell.textLabel.text = [self.filteredItemsArray objectAtIndex:indexPath.row];
if([self.checkMarkSignalArray objectAtIndex:indexPath.row]){
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}

How to fix size of text in UITextField so it should not overlap the label?

I've a UITextField and a UILabel on it. The label is right aligned and the text is left aligned, the problem is that when i enter text in text field, whenever the size of text goes bigger it overlap the label.
How can i prevent the label to be overlapped?
Updated:-you can use table view cell of type value1 or value2 that gives you this format and Used TextLabel as main heading and place the textfield in place of detailtext.That can be fix.

How to "insert" text into UITextField?

I'm trying to insert a text into a UITextField. But by insert, I mean replacing the character at cursor position with the new one (insert button's functionality on windows).
If I manually replace the incoming string and do setText (with NO returned to shouldChangeCharactersInRange method), the cursor moves to the end of textField.
For UITextField (iOS 3.2+), try:
[textField replaceRange:[textField selectedTextRange] withText:toInsert];
You can replace the text as you have done previously and restore the position of your caret. Note that this can only be done with UITextView rather than UITextField (that would require a lot more unjustified work, unless you absolutely have to use UITextField):
NSRange selectionRange = myTextView.selectedRange;
myTextView.text = myNewText;
myTextView.selectedRange = selectionRange;
You have to note that it's a good idea to check the validity of selectionRange variable for new text - make sure that cursor position isn't greater than the new text length.

Deleting a line of text on an NSTextView

I have a NSTextView called TheTextView. I'm adding there lines of text, each line representing a full path to a file with a \n at the end. The textview is set to not editable. I add or remove text via a + and - buttons.
Supposedly the user can select a line and delete it. I've tried with
[TheTextView delete:nil];
But nothing happens. How can I delete the selected line? And while we are in this topic, is there any way to set the TextView to select the whole line when I click on one line?
Thanks
EDIT:
OK, so I found that if I do the following
[TheTextView setEditable:YES];
[TheTextView delete:nil];
[TheTextView setEditable:NO];
then it works. Now I need to know how to select the entire line when the user click it because otherwise it will leave a blank space in between the two lines where the one deleted was. Ideas?
It sounds like no text is selected when you call [TheTextView delete:nil]. Try calling setSelectedRange: with a range to select a line of text, then try calling delete:. For example:
[TheTextView setSelectedRange:NSMakeRange(0,24)];
[TheTextView delete:nil];
Of course, you'll need to determine the correct start and length of your range to correspond the text you want to delete.

Clear text of UITextField in UITableView cell on button press

I have a table view with two rows, each with a text field. One text field is for username and the other for password. When I click on a button, I want to clear both fields and replace the contents with the intial placeholders.
I tried [mytableview reloadData];. That just reloads the table view; the text fields are not cleared. The placeholders are appearing over the text entered while editing the text field, and the next time I try to edit the text field, the text is drawn over the first text.
on your button click:-
do yourtextfieldname.text=#"";
or if you have made a text field in table view methods so in that condition on your button click do [tableView reloadData] and at cellForRowAtIndexPath write yourtextfieldname.text=#"";
and set placeholder also.