I have a UITableView inside UiViewController.
In the same screen, I also have two buttons: Show All vs Show Top 5.
Now based on a selection all/top 5, I have to update table data.
I cant use [tableView reloadData] as I am not using UITableViewController.
This is the first time I am working on an iphone app. So any help is appreciated.
(I used this tutorial to get started http://www.icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/)
Thanks.
Here is a snippet of my code:
.h file
@interface DataViewController : UIViewController {
NSString *showType;
}
@property (nonatomic, retain) NSString *showType;
-(IBAction) showTop: (id) sender;
-(IBAction) showAll: (id) sender;
@end
.m file
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"customCell";
DataCustomCell *cell = (DataCustomCell *) [tableView dequeueReusableCellWithIdentifier:cellID];
if([showType isEqualToString:@"all"])
{
// use this data..
}
else
{
// use some other data..
}
// ....
}
-(IBAction) showNearby: (id) sender
{
self.showType=@"top";
// reload table some way
}
-(IBAction) showAll: (id) sender
{
self.showType=@"all";
//reload table some way
}
Create a UITableView IBOutlet like this
in your UIViewController’s interface file. Then have that connect to the UITableView in Interface Builder. After synthesizing it in your implementation file, you should be able to access it like this
[self.myTableView reloadData];Also, since you retained it, you will have to release myTableView in the
deallocmethod.