UITableViewCellの変数を再割り当てし、TWTweetComposeViewControllerでツイートするようになりましたが、問題が発生しました。 UITableViewの最後の行から変数をtweetingします。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;
メインビューコントローラのセットアップ:
// 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