Мне удалось переназначить переменные UITableViewCell и получить его для чириканья с TWTweetComposeViewController, но у меня возникла проблема. Он всегда чирикает переменные из последней строки в UITableView.Назначение переменных из UITableViewCell для твитов в главном контроллере представления
Вот моя установка: у меня есть 1 кнопка твитта и 4 UILabels в UITableViewCell. 4 UILabels извлекают информацию из Plist для заполнения таблицы. В каждой ячейке есть кнопка твита, чтобы чирикать информацию о ячейке, но тут я столкнулся с проблемой. Он всегда считывает информацию из последней строки таблицы, а не строку, в которой он находится. Любая помощь с благодарностью.
установка UITableViewCell.h
@property (nonatomic, strong) IBOutlet UILabel *playerOneLabel;
@property (nonatomic, strong) IBOutlet UILabel *playerOneScoreLabel;
@property (nonatomic, strong) IBOutlet UILabel *playerTwoLabel;
@property (nonatomic, strong) IBOutlet UILabel *playerTwoScoreLabel;
Главная View Controller:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ScoreListCell";
ScoreCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
NSDictionary * dictionary = [scoresArray objectAtIndex:indexPath.row];
cell.playerOneLabel.text = [dictionary objectForKey:@"playerOneName"];
cell.playerOneScoreLabel.text = [dictionary objectForKey:@"playerOneScore"];
cell.playerTwoLabel.text = [dictionary objectForKey:@"playerTwoName"];
cell.playerTwoScoreLabel.text = [dictionary objectForKey:@"playerTwoScore"];
self.player1Name = cell.playerOneLabel;
self.player1Score = cell.playerOneScoreLabel;
self.player2Name = cell.playerTwoLabel;
self.player2Score = cell.playerTwoScoreLabel;
return cell;
}
и, наконец, установка твит в главном контроллере представления:
- (IBAction)twitter:(id)sender {
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
NSString *text = [NSString stringWithFormat:@"%@-%@, %@-%@",
player1Name.text, player1Score.text, player2Name.text, player2Score.text];
[tweetSheet setInitialText:text];
[self presentModalViewController:tweetSheet animated:YES];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Sorry"
message:@"Tweet unsuccessful. Make sure your device has an internet connection and you have a Twitter account."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
вы должны добавить теги к каждой метке, а затем получить доступ к ним с помощью тега через параметр отправителя – cpjolicoeur