0
テーブルセルに値を渡そうとしていますが、文字列をuserdata.titleに置き換えると、 は空白になります。 userdataは外部のUserDataという別のクラスのオブジェクトで、インポートします。 UserDataはすべてのビューからアクセスされ、あるコントローラから別のコントローラにオブジェクトを渡します。今、テーブルに値を渡すにはどうすればいいですか?テキストフィールドで値を追加する場合は、どうすれば保持できますか?テーブルセルにデータを渡す
- (void)viewDidLoad
{
tabledata = [[NSMutableArray alloc] initWithObjects:@"hello", nil];
tablesubtitles = [[NSMutableArray alloc] initWithObjects:@"hello", nil];
[super viewDidLoad];
//if I use "userdata.title" in replacemnent of @"hello" above, the table show up blank
//self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
//--------------------------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
return [tabledata count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"homeworkcell"];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"homeworkcell"];
}
cell.textLabel.text = [tabledata objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [tablesubtitles objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
//static NSString *CellIdentifier = @"Cell";
/* if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}*/
// Configure the cell.
//-----------------------------------------START----------------------------Set image of cell----
cellImage = [UIImage imageNamed:@"checkboxblank.png"];
cell.imageView.image = cellImage;
//--------------------------------------------END---------------------------end set image of cell--
return cell;
}
userDataをこのクラスに渡す方法は? – beryllium
#import "UserData.h"次にUserData * userdata; – user1191343
これは通過ではなく、ヘッダーのインポートに過ぎません。作成する場所、テーブルのデータソースとしてinitとsetup? – beryllium