私は FBFriendPickerViewController を促す ViewController を持っています。選択時に、選択を含む NSArray が返されます。ここで、この選択情報を使用して新しい ViewController を表示して表示したいと思います。私は Objective C を初めて使用しますが、解決策はかなり単純だと思います。これが私の提案です:
ViewController2.h
- (id)initWithStyle:(UITableViewStyle)style andSelection:(NSArray *)selection;
@property (strong, nonatomic) NSArray *selectedParticipants;
ViewController2.m
- (id)initWithStyle:(UITableViewStyle)style andSelection:(NSArray *)selection {
self = [super initWithStyle:style];
if (self) {
self.title = NSLocalizedString(@"Split Bill", nil);
self.tableView.backgroundColor = [UIColor wuffBackgroundColor];
self.selectedParticipants = selection;
}
return self;
}
- (void)setSelectedParticipants:(NSArray *)selectedParticipants {
NSLog(@"setSelectedParticipants (%d)", [selectedParticipants count]);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"%d rowsInSection", [self.selectedParticipants count]);
return [self.selectedParticipants count];
}
ViewController1.m
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 2) {
[[self friendPickerController] presentModallyFromViewController:self animated:YES handler:^(FBViewController *sender, BOOL donePressed) {
if (donePressed) {
ViewController2 *vc = [[ViewController2 alloc] initWithStyle:UITableViewStyleGrouped
andSelection:[self.friendPickerController selection]];
[self.navigationController pushViewController:vc animated:YES];
}
//[[self friendPickerController] clearSelection];
}
];
}
}
ただし、最初の setSelectedParticipants-log は選択されたフレンドの正しい数を返すようですが、numberOfRowsInSection-log は 0 を返します。
どうしてこれなの?
前もって感謝します!