カスタムセルを追加しています。誰かが追加ボタンを押すたびに、アラート ビューがポップアップ表示され、Web サイトの名前が追加されます。保存を押すと、選択した名前でテーブル ビュー セルに保存されます。次に、誰かがそのセルをクリックすると、Web ビューで http:// をロードします。唯一の問題は、ロードされていないことです。私は何を間違っていますか?
これは私のテーブルビューコントローラーです
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"cellTwo";
UITableViewCell *cell = [myTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
if (indexPath.section == 0) {
cell.textLabel.text = [NSString stringWithFormat:@"%@",[tableData objectAtIndex:indexPath.row]];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Index Selected,%d",indexPath.row);
MainTwoViewController *View = [self.storyboard instantiateViewControllerWithIdentifier:@"mainTwo"];
View.urlString = [[NSString alloc] initWithFormat:@"http://www.%@",tableData];
View.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
//Only do the following action if the user hits the ok button
if (buttonIndex == 1) {
NSString *tapTextField = [alertView textFieldAtIndex:0].text;
if (!tableData) {
tableData = [[NSMutableArray alloc]init];
}
[tableData insertObject:tapTextField atIndex:0];
[myTableView reloadData];
}
そしてもちろん、これをmainTwoビューコントローラーに入れて、urlStringをロードします。
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];