Skip to main content

Posts

Showing posts with the label uitableview

How to stop UITextView from scrolling up when entering it

I have a UITextView included in a UITableViewCell . The layout is correct when the views are initially displayed, but once I click in the UITextView it automatically scrolls up a bit and the top half of the characters on the first line becomes invisible.

Custom UITableViewCell redraw issues

I have a custom UITableView cell that I've added a textbox to for editing, that shows and hides based on the edit mode. I've also tried adding a vertical line that shows when editing, and it does that, but I'm running into some drawing issues. I just added a green checkmark rightView to start working on input validation feedback, and I'm seeing similar issues.

Long press on UITableView

I would like to handle a long press on a UITableViewCell to print a "quick access menu". Does someone already did this ? Particularly the gesture recognize on UITableView ? Source: Tips4all

Changing the size of the UISearchBar TextField?

I have a UITableView with an Index on the side; I want to add a UISearchBar to it, but the index overlaps with the "x" to clear the search. I've noticed in the Contacts application, the textfield within the UISearchBar is resized to accommodate this, but I can't work out how to do this in my own app. I have tried the following in my viewDidLoad, but it does not seem to work. UITextField * textField = (UITextField *)[[self.search subviews] objectAtIndex:0]; CGRect r = textField.frame; [textField setFrame:CGRectMake(r.origin.x, r.origin.y, r.size.height, r.size.width-30)]; Any ideas? Source: Tips4all

iPhone - Setting background on UITableView

Is there any way to set a background view on a UITableViewController? I try with the code I am using on a UIViewController, but the view comes over all the contents of the table view, and if I add the background view in the cellForRowAtIndexPath-method, it is not showing at all. Anyone done this before or have an idea on how it can be done? Here is the code I am using: UIImage *image = [UIImage imageNamed: @"background.jpg"]; UIImageView *backImage = [[UIImageView alloc] initWithImage: image]; [self.view addSubview: backImage]; [self.view sendSubviewToBack: backImage]; Thanks Source: Tips4all

insertSubview:belowSubview: in UITableViews

I have a UITableView with UITableViewCell s that are swipable. When a cell is swiped, I want a view to be visible (revealed) underneath that cell. Here's the code that I have: UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; _cellBack = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; _cellBack.backgroundColor = [UIColor whiteColor]; [self.tableView insertSubview:_cellBack belowSubview:cell]; for (int i = 0; i < [self.tableView subviews].count; i++) { UIView *v = [[self.tableView subviews] objectAtIndex:i]; if ([v isEqual:_cellBack]) { NSLog(@"cellBack %d", i); } if ([v isEqual:cell]) { NSLog(@"cell %d", i); } } In the for loop, I check to see if the views' indexes are as I expect, and indeed they are; _cellBack has an index that is one less than cell 's index. When I replace the insertSubview:belowSubview: call wit

add uiview at row selection

I want when tab on row a uiview containing two button appear at the center of the cell, so I did the following code - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //how can I get the text of the cell here? UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIView *v = [[UIView alloc] init]; v.center = cell.center; UIButton*button1 =[[UIButton alloc] init]; button1.frame = CGRectMake(v.center.x - 5 , v.center.y , 5 , v.center.y + 4 ); button1.titleLabel.text = @"I'm label 1"; [v addSubview: button1]; UIButton*button2 =[[UIButton alloc] init]; button2.frame = CGRectMake(v.center.x - + 1 , v.center.y , 5 , v.center.y + 4 ); button2.titleLabel.text = @"I'm label 2"; [v addSubview: button2]; [cell addSubview:v]; /* <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"&

UITableView&hellip;the correct way

I'm trying to make a UITableView like the native calendar app: but I'm trying to learn the best way to do this. I'm able to get this for the most part with a switch statement in the cellForRowAtIndexPath method, but I'm having troubles changing the textColor when a cell is selected. For some reason cell.isSelected is always NO, and I have no way to reload the tableview after another cell is selected anyway. Should I subclass UITableViewCell for something this simple and store an array of cells? Any help would be appreciated, thanks.

uitableView reloadData doesn"t work after setting delegate, datasource and file"s owner connection

I have googled and done lot of research from my side to find out why the reloadData method on tableview wouldn't work. I checked all the possible solutions like the datasource is set, delegate is set, the tableview is connected to the file's owner. After all these, when I am trying to reload the tableview, the no. of rows method gets called, but the cell for rowAtIndexPath doesn't get called. Below is the code that I have written. Please let me know, where I am going wrong - (void)onReservationListSuccess:(NSArray *)rData { if ( rData != nil ) { resList = [[NSArray alloc] initWithArray:rData]; if([resList count] > 0) { [self.tripsTableView reloadData]; //[self.tripsTableView beginUpdates]; //[self.tripsTableView reloadSections:[NSIndexSet indexSetWithIndex:0] // withRowAnimation:UITableViewRowAnimationNone]; //[self.tripsTableView endUpdates]; } else { [tripsTableView reloadData];

How to push DetailView without NavigationController on UIViewController

I have a ViewBased App. I added a UITableView on one of the UIViewControllers. It shows the data and I implemented all the delegate methods etc. My problem is when I want to show the detailView it just doesn't happen. My code: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DetailViewController *detailViewController =[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; NSLog(@"DidSelectRowAtIndexPath"); // Pass the selected object to the new view controller. [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; } I see that I need a navigationController but I don't have one and I was unsucessful trying to add one programatically. I don't have one in my appDelegate either, so my question is do I need to add one to show the detail view? If yes, please give me a code sample

How to put a UITableView below a UILabel with code

I wrote a code with a UILabel with the name of a meteorological station. Later, I added the code to put a UITableView with a grid view like this website explains http://www.recursiveawesome.com/blog/2011/04/06/creating-a-grid-view-in-ios/ The problem is that now the Table view is shown in all screen and the label can't be seen. How do I make to put the elements in this order? UILabel UITableView Thanks!

Crashed when deleting a row from UItableview

When deleting a row from Uitableview using commitEditingStyle, my app crashes with this error. Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046 .Terminating app due to uncaught exception NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). This is my code: - (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // If row is deleted, remove it from the list. if (editingStyle == UITableViewCellEditingStyleDelete) {

Adding Accessory to UITableView

I've got a UITableView displayed on screen for a while. In each cell is a song and artist name. In the background, each song and artist name is searched for online (using the Spotify API). It finds the URL to play one song, and then moves on to the next one! :) Sounds simple... but what I want is when each song is found, for the Checkmark accessory to appear in that row. Currently i've got the following code to do this... [[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:currentConnectionNumber inSection:0]] setAccessoryType:UITableViewCellAccessoryCheckmark]; [table setNeedsDisplay]; But all that happens is when all of the songs has been found, THEN the checkmarks appear... Why is this and how can I make the checkmarks appear one at a time? thanks

error with scrollToRowAtIndexPath

I am getting an error when using my application that used tableviews, the error looks like this. 2012-01-19 10:19:51.442 bcode[1176:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: row (3) beyond bounds (3) for section (0).' *** First throw call stack: (0x16c3052 0x1920d0a 0x166ba78 0x166b9e9 0x68a136 0x3bfdf 0x6c2fbf 0x6c32d4 0x6c35d7 0x6d2666 0x87890e 0x878c17 0x878c86 0x62c499 0x62c584 0x2718e00 0x13614f0 0x15fa833 0x15f9db4 0x15f9ccb 0x1d05879 0x1d0593e 0x5fba9b 0x2838 0x2795 0x1) terminate called throwing an exception(gdb) What is happening is that when the user drills down my navigation view they can select a cell from the tableview of each view, which later will be used to build a search string. However I allow them to go back and change their selection if they made an error.. this error happens when the user changes the value of the parent view then going into

Delete UITableViewCell and ALL of that cell"s data

I have a UITableViewCell. I can add and subtract 1 from the cell's textLabel and I can also delete the cells. Here is my problem, Lets say i add 5 to the value of the textLabel . And this cell is at the 0 indexPath (The First cell in the table). When I delete this cell and there are now no longer any cells on the table, I add a new cell and this new cell automatically gets the same value as the cell that was just deleted. SO this new cell will have a value of 5 and i want the cell to have a value of 1 just like every cell should when it is added. This only happens when a cell is deleted and a new cell is added at that exact same indexPath. So my question is: do i have to delete this cells "memory" or "data" for this to be fixed? Thanks a bunch for the help! CellForRowAtIndexPath : - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; cell = [