UITableView
このテーブルを含むビューをナビゲートするたびに更新しようとしています。
コントローラー内に含まれているを使用して、アプリケーションの起動時にテーブルを正しく設定するViewController
カスタムがあります。UITableViewController
NSMutableArray
テーブルを含むページに移動するViewController
と、HTTP 要求でサーバーからデータを取得し、NSMutableArray
.
ここに私の問題があります。この配列を自分のに送信することUITableViewController
に成功しましたが、tableView を更新しても何も起こりません。
を使用しようとしましたが、numberOfRowsInSection または関数[myTable reloadData]
を呼び出しません。cellForRowAtIndexPath
同じ問題を抱えている人が を使用して解決したのを見ました[self.myTable ReloadData]
が、エラーが発生します:
不明な getter/setter メソッドへのアクセス
私は Objective-C にかなり慣れていませんが、このエラーは少しランダムに発生するため、まだ少し不思議です。
UITableViewController
いずれにせよ、 の宣言(どこで宣言すればよいか) と Interface Builder のリンクをめちゃくちゃにした可能性が高いため、これが解決策を見つける手がかりになる可能性があります。
誰にもアイデアがありますか?
どうもありがとうございました!
編集:これが私のテーブルビューコントローラークラスです:
#import "MyCell.h"
@class Mycell;
@interface MyTableController : UITableViewController {
IBOutlet MyCell * myCell;
IBOutlet UITableView * myTable;
NSMutableArray *data;
}
@property (nonatomic, retain) IBOutlet UITableView * myTable;
- (void) EditTable : (NSMutableArray*) param;
@end
そして今、.m:
@implementation MyTableController
@synthesize myTable;
- (void) viewDidLoad {
[super viewDidLoad];
myTable = [[UITableView alloc] init];
data = [[NSMutableArray alloc] init];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MyCell";
MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; >
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (MyCell *) currentObject;
}
}
}
NSString *datastring = [listenom objectAtIndex:indexPath.row];
[cell setCell: datastring ];
return cell;
}
- (void) EditTable : (NSMutableArray*) param{
//This function is called by the ViewController when the user goes to the page containing the view
data = param; //The param array contains the data from the HTTP request
[self.tableView reloadData];
[self.myTable reloadData]; //I tried both, but only the first one actually calls the previous functions
}