uitableview interview questions
Top uitableview frequently asked interview questions
i am trying to display a simple UITableView
with some data. I wish to set the static height of the UITableView
so that it doesn't displays empty cells at the end of the table. how do I do that?
code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"%d", [arr count]);
return [arr count];
}
Source: (StackOverflow)
I would like to handle a long press on a UITableViewCell
to print a "quick access menu".
Did someone already do this?
Particularly the gesture recognize on UITableView
?
Source: (StackOverflow)
I thought this information would have been easier to find :-)
What is the default height of a UITableViewCell? It looks like 44 pixels, but I'd prefer to be sure.
Source: (StackOverflow)
I would like to customize the background (and maybe the border too) of all of the UITableViewCells within my UITableView. So far I have not been able to customize this stuff, so I have a bunch of white background cells which is the default.
Is there a way to do this with the iPhone SDK?
Source: (StackOverflow)
How do I get the delete button to show when swiping on a UITableViewCell
?
I have followed this post, but the event is never raised and the delete button never appears!
Source: (StackOverflow)
How do you use Auto Layout within UITableViewCell
s in a table view to let each cell's content and subviews determine the row height, while maintaining smooth scrolling performance?
Source: (StackOverflow)
I am trying to adjust the cell height for one of the cells on my table view. I am adjusting the size from the "row height" setting inside the "size inspector" of the cell in question. When I run the app on my iPhone the cell has the default size set from the "row size" in the table view.
If I change the "row size" of the table view then the size of all cells changes. I do not want to do that as I want a custom size only for one cell. I have seen a lot of posts that have a programmatic solution to the problem, but I would prefer to do it through storyboard, if that is possible.
Source: (StackOverflow)
When you tap a row in a UITableView
, the row is highlighted and selected. Is it possible to disable this so tapping a row does nothing?
Source: (StackOverflow)
I have an app where the UITableView
's separator inset is set to custom values - Right 0
, Left 0
. This works perfectly in iOS 7.x, however in iOS 8.0 I see that the separator inset is set to the default of 15
on the right. Even though in the xib files it set to 0
, it still shows up incorrectly.
How do I remove the UITableViewCell separator margins?
Source: (StackOverflow)
I'm new to iOS and, Objective-C and the whole MVC paradigm and I'm stuck with the following:
I have a view that acts as a data entry form and I want to give the user the option to select multiple products. The products are listed on another view with a UITableView
controller and I have enabled multiple selections.
My question is, how do I transfer the data from one view to another? I will be holding the selections on the UITableView
in an array, but how do I then pass that back to the previous data entry form view so it can be saved along with the other data to core data on submission of the form?
I have surfed around and seen some people declare an array in the app delegate. I read something about Singletons but don't understand what these are and I read something about creating a data model.
What would be the correct way of performing this and how would I go about it?
Source: (StackOverflow)
Starting in iOS7, there is additional space at the top of my UITableView
's which have a style UITableViewStyleGrouped
.
Here is an example:
The tableview starts at the first arrow, there is 35 pixels of unexplained padding, then the green header is a UIView
returned by viewForHeaderInSection
(where the section is 0).
Can anyone explain where this 35 pixel amount is coming from and how I can get rid of it without switching to UITableViewStylePlain
?
Source: (StackOverflow)
I'm having an issue with UITableView's
didSelectRowAtIndexPath
.
My table is setup so that when I select row it initializes a new view controller and pushes it.
The first time I tap any row in the table, the method does not get called. Once I select another row, it begins to work as normal.
I have verified this by setting a breakpoint on didSelectRowAtIndexPath
. When adding an NSLog
to the method I see that when I select the second row that finally pushes the new view controller, I see two log statements appear in the console at the same time.
Any suggestions?
Source: (StackOverflow)
I have many annotations in a mapview (with rightCalloutAccessory
buttons). The button will perform a segue from this mapview
to a tableview
. I want to pass the tableview
a different object (that holds data) depending on which callout button was clicked.
For example: (totally made up)
- annotation1 (Austin) -> pass data obj 1 (relevant to Austin)
- annotation2 (Dallas) -> pass data obj 2 (relevant to Dallas)
- annotation3 (Houston) -> pass data obj 3 and so on... (you get the
idea)
I am able to detect which callout button was clicked.
I'm using prepareForSegue
: to pass the data obj to the destination ViewController
. Since I cannot make this call take an extra argument for the data obj I require, what are some elegant ways to achieve the same effect (dynamic data obj)?
Any tip would be appreciated.
Source: (StackOverflow)
So I was making an rss reader for my school and finished the code. I ran the test and it gave me that error. Here is the code it's referring to:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
if (cell == nil) {
cell =
[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}
here's the error in the output:
2012-10-04 20:13:05.356 Reader[4390:c07] * Assertion failure in
-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460 2012-10-04
20:13:05.357 Reader[4390:c07] * Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'unable to
dequeue a cell with identifier Cell - must register a nib or a class
for the identifier or connect a prototype cell in a storyboard'
* First throw call stack: (0x1c91012 0x10cee7e 0x1c90e78 0xb64f35 0xc7d14 0x39ff 0xd0f4b 0xd101f 0xb980b 0xca19b 0x6692d 0x10e26b0
0x228dfc0 0x228233c 0x228deaf 0x1058cd 0x4e1a6 0x4ccbf 0x4cbd9 0x4be34
0x4bc6e 0x4ca29 0x4f922 0xf9fec 0x46bc4 0x47311 0x2cf3 0x137b7 0x13da7
0x14fab 0x26315 0x2724b 0x18cf8 0x1becdf9 0x1becad0 0x1c06bf5
0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x147da 0x1665c 0x2a02 0x2935)
libc++abi.dylib: terminate called throwing an exception
and here's the code it shows in the error screen:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
please help!
Source: (StackOverflow)
I have created a custom UITableViewCell
. The table view is showing data fine. What I am stuck in is when user touches cell of tableview, then I want to show the background color of the cell other than the default [blue color] values for highlighting the selection of cell.
I use this code but nothing happens:
cell.selectedBackgroundView.backgroundColor=[UIColor blackColor];
Source: (StackOverflow)