テーブルビューには非常に多くの行があります。テーブルビュー行をクリックすると、上記の例のように展開されます。 特定のUITableView行をクリックした後にWebViewデータを表示する方法は?
このように、他のデータを表示したいので、次のビューに移動したくありません。
ここで別のポイントは、展開するときに特定の行をクリックした後、ここで私はWebビューを表示したいと思います。私のプロジェクトでは、一部のデータはメッセージの一部のテキスト行であるか、ウェブページである可能性があります。 したがって、Webビューも表示する必要があり、データまたはWebコンテンツに従って動的にtableviewセルを調整する必要があります。
このように、任意のセルをクリックすると展開してウェブビューを表示する必要があります。いつかは、ウェブデータが含まれていない場合でも、いくつかのメッセージが含まれている可能性があります。
ここに私の現在のプロジェクトサンプルがあります。私は次のようにデータ/情報を表示しています。 これは私のテーブルビューです(画像1を参照)。これをクリックすると、このようなポップアップが表示されます(画像2を参照) - このようなメッセージが表示され、画像3 - Webデータ/ webviewが含まれます。
誰かが解決策を知っている場合は、解決策を投稿してください。ありがとうございました..!ここで
ちょうど2つの異なるテーブルビューセルをデザインシンプルで私のdidSelectRowAtIndexPath方法、
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSDictionary *finaldic=[mutableArray objectAtIndex:indexPath.row];
[self showWebview:@"" body:[finaldic objectForKey:@"body"] popupStyle:CNPPopupStyleActionSheet];
}
とWebViewの方法、
-(void)showWebview:(NSString*)tittle body:(NSString*)body popupStyle:(CNPPopupStyle)popupStyle{
NSMutableParagraphStyle *paragraphStyle = NSMutableParagraphStyle.new;
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSTextAlignmentCenter;
NSAttributedString *title = [[NSAttributedString alloc] initWithString:tittle attributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:14], NSParagraphStyleAttributeName : paragraphStyle}];
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.numberOfLines = 0;
titleLabel.attributedText = title;
// UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
// customView.backgroundColor = [UIColor hx_colorWithHexString:@"#00aeef"];
// [customView addSubview:titleLabel];
UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width,self.view.frame.size.height/2)];
// webview.scalesPageToFit = YES;
webview.autoresizesSubviews = YES;
//webview.delegate=self;
webview.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
NSRange range = [body rangeOfString:@"<body"];
if(range.location != NSNotFound) {
// Adjust style for mobile
float inset = 40;
NSString *style = [NSString stringWithFormat:@"<style>div {max-width: %fpx;}</style>", self.view.bounds.size.width - inset];
body = [NSString stringWithFormat:@"%@%@%@", [body substringToIndex:range.location], style, [body substringFromIndex:range.location]];
}
[webview loadHTMLString:body baseURL:nil];
self.popupController = [[CNPPopupController alloc] initWithContents:@[titleLabel,webview]];
self.popupController.theme = [CNPPopupTheme defaultTheme];
self.popupController.theme.popupStyle = popupStyle;
self.popupController.delegate = self;
[self.popupController presentPopupControllerAnimated:YES];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
}
-(void)webViewDidStartLoad:(UIWebView *)webView{
}
あなたは客観的なcまたはswiftを使用していますか? –
試したコードを追加してください。 –
@ R.Mohanこれは目的コードです。 –