Dans la vue de table il y a tellement de rangées, quand je clique sur n'importe quelle rangée de vue de table elle développera comme l'exemple ci-dessus. Comment afficher les données WebView après avoir cliqué sur une ligne UITableView particulière?
Donc, de cette façon, je veux montrer d'autres données, je ne veux pas passer à la vue suivante.
Voici un autre point, après avoir cliqué sur une ligne particulière quand elle se développe alors ici je veux montrer la vue web. Dans mon projet, certaines données sont des messages certaines lignes de texte ou peuvent être une page Web. Ainsi, il doit également afficher la vue Web et ajuster dynamiquement la cellule tableview en fonction des données ou du contenu Web. Ainsi, si vous cliquez sur une cellule, elle doit être agrandie et afficher la vue Web. Même parfois, il ne contient pas de données Web peuvent contenir des msg alors il doit être l'affichage web.
Voici mon exemple de projet actuel. J'affiche les données/informations de la manière suivante. Voici ma vue de la table (voir image 1) et après avoir cliqué sur la ligne, elle affiche une fenêtre comme celle-ci (voir image 2) - Elle contient un message comme celui-ci, et l'image 3 - contient données web/webview.
Si quelqu'un connaît la solution, veuillez poster la solution. Je vous remercie..!
Voici ma méthode de didSelectRowAtIndexPath,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSDictionary *finaldic=[mutableArray objectAtIndex:indexPath.row];
[self showWebview:@"" body:[finaldic objectForKey:@"body"] popupStyle:CNPPopupStyleActionSheet];
}
et méthode 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{
}
vous utilisez l'objectif c ou rapide? –
Ajoutez votre code essayé. –
@ R.Mohan Ceci est le code Objective c. –