我有UiViewController內的UITableView。 在同一屏幕上,我也有兩個按鈕:Show All vs Show Top 5.如何重新加載UiViewController內的UItableView
現在基於選擇全部/前5位,我必須更新表格數據。
我不能使用[tableView reloadData],因爲我沒有使用UITableViewController。
這是我第一次在iphone應用上工作。所以,任何幫助表示讚賞。
(我用這個教程上手http://www.icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/)
感謝。
這裏是我的代碼片段:
.h文件中
@interface DataViewController : UIViewController {
NSString *showType;
}
@property (nonatomic, retain) NSString *showType;
-(IBAction) showTop: (id) sender;
-(IBAction) showAll: (id) sender;
@end
.m文件
- (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
{
[email protected]"top";
// reload table some way
}
-(IBAction) showAll: (id) sender
{
[email protected]"all";
//reload table some way
}
謝謝它的工作..完美... – priyank