Blockquote
How to set the position of refresh controller in iOS at the end of table.
After last data refresh
controller must be shown
Try this -
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return arrData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
if (arrData.count==indexPath.row+1) {
//call reload method & reload tableView
}
...
}
Related
i have a UITableView to show pictures ,each picture has a name;for some reason, i have to make the name as a section header,and the picture as a section row,the major code is like this:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [dataList count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
...
return view;
}
the picture is as big as 640*640;
my problem is : every time ,the picture will not load until its top shows in the screen;
i want to load many pictures at a time ,but the fact is a picture is loaded when its top shows in the screen;
Since the delegate method that asks you for a cell won't get called until a new cell is about to get into the view, you have to preload images somewhere outside the delegate method.
First of all this is not a duplicate as I have read through very similarly titled questions but they do not give me the correct answer!
So what I have done is:
First of all create a Table View with 13 unique (contain different buttons) prototype cells where the table views content is "Dynamic Prototypes". I then created a UITableViewCell class called blurCell.
I can see the new/second UITableView but there are no cells within it?
I currently have (for the first UITableView) the code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 25;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
}
But I did this because I was using a .xib for this table.
Do I need this kind of code for the new/second UITableView as I have done everything manually in the storyboard?
Please help?
In the ViewController.m (ImagesTableViewController) that contains these two tables I have the code:
#interface ImagesTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
Which is linked to both tables
Each tableView should be declared as its own property with the delegate/data source set to self most likely in viewDidLoad
You need to do something like this for the delegate/data source methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(tableView==firstTableView) return 25;
else if(tableView==secondTableView) return 2;
else return 15;
return 0;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
if(tableView==firstTableView) return 1;
else if(tableView==secondTableView) return 2;
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{...}
I have a UItableViewController inside a containerView and when I touch in one of my cells, it doesn't call didSelectRowAtIndexPath. However, if I long press, this method is called normally.
I've used storyboard and my delegate and datasource are my tableViewController.
Here is my tableViewController code:
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return nuberOfSections;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return nuberOfSections;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return heightForHeader;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MWSideMenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"menuCell"];
// cell settups
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// Some action done
}
There could be three reasons
delegate is not set
Could be a typo in the didselectrowatindexpath
gesture recognizers might be used in container VC or containing VC
same problem happened with me because I have added a tap gesture recogniser over it. `
If you have used any gesture try removing it
` and check if it causing the problem.
I want to add search bar to UITableView header, it's visible on IB but not on emulator after running
Check that you are actually calling- initWithNibName: bundle: method properly.
Actually headers are the part of section in table view, so ur view controller class must conform to UITableViewDelegate protocol and must implements the method
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
and for customization of ur header view use
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
example
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 25.0f;
}
or you can use UITableViewDataSource method
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return #"#";
}
I'm trying to delete a row using Xcode 4.2 and a storyboard. The Table is nested in a UINavigationController nested in a UITabBarController.
My UITableViewDelegate class implements the following code:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCellEditingStyle result = UITableViewCellEditingStyleNone;
if ([tableView isEqual:self.tableView]==YES) {
result = UITableViewCellEditingStyleDelete;
NSLog(#"hi");
}
return result;
}
and when I swipe a row, I see the "hi" message in the log, but the row never receives a "Delete" button. Looking at sources like http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1, my
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(#"hi2");
}
method is never called.
Thanks!
Check if method - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath returns YES for appropriate index paths.