Tengo un problema extraño con loadHTMLString de UIWebView, donde solo mostraría una vista en blanco cuando llame a loadHTMLString con mi cadena HTML de contenido. No importa cuál sea el contenido de htmlstring, simplemente no hace nada.UIWebView loadHTMLString muestra la pantalla en blanco
Lo extraño es que solía funcionar hace unas semanas, cuando lo probé en el simulador y el dispositivo. Mi código es el siguiente:
NSMutableString *sHtmlBuf = [NSMutableString stringWithString:@"<body style=\"background-color: #000000; color: #FFFFFF; font-family: Helvetica; font-size: 10pt; width: 300px; word-wrap: break-word;\">"];
if ([m_oCallArray count] > 0 || [m_oPutArray count] > 0) {
[sHtmlBuf appendString:sWarrTitle];
if ([m_oCallArray count] > 0) {
NSString *formattedCall = [NSString stringWithFormat:@"%@ %@<br />",sCallTitle,[self arrayToString:m_oCallArray]];
[sHtmlBuf appendFormat:@"%@ ",formattedCall];
}
if ([m_oPutArray count] > 0) {
NSString *formattedPut = [NSString stringWithFormat:@"%@ %@<br />",sPutsTitle,[self arrayToString:m_oPutArray]];
[sHtmlBuf appendFormat:@"%@ ",formattedPut];
}
}
if ([m_oBullArray count] > 0 || [m_oBearArray count] > 0) {
[sHtmlBuf appendString:sCbbcTitle];
if ([m_oBullArray count] > 0) {
NSString *formattedBull = [NSString stringWithFormat:@"%@ %@<br />",sBullTitle,[self arrayToString:m_oBullArray]];
[sHtmlBuf appendFormat:@"%@ ",formattedBull];
}
if ([m_oBearArray count] > 0) {
NSString *formattedBear = [NSString stringWithFormat:@"%@ %@<br />",sBearTitle,[self arrayToString:m_oBearArray]];
[sHtmlBuf appendFormat:@"%@ ",formattedBear];
}
}
if ([m_oOtherArray count] > 0) {
NSString *formattedOther = [NSString stringWithFormat:@"%@ %@<br />",sOtherTitle,[self arrayToString:m_oOtherArray]];
[sHtmlBuf appendFormat:@"%@ ",formattedOther];
}
[m_oDataPresentView loadHTMLString:sHtmlBuf baseURL:nil];
(Nota: el código HTML puede hacer en un navegador web normal antes de este problema, por lo que el HTML no es un problema)
EDIT: Añadido código de inicialización:
//Create wcbbc panel
wcbbcPanel = [[WarrantsAndCbbc alloc] initWithFrame:CGRectMake(320, 0, 320, 230)];
[m_oMainContentScrollView addSubview:wcbbcPanel];
UIView código de inicialización:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code.
CGRect oFrame = frame;
CGPoint oPositionCoords = CGPointMake(0, 0);
oFrame.origin = oPositionCoords;
m_oDataPresentView = [[UIWebView alloc] initWithFrame:oFrame];
[m_oDataPresentView loadHTMLString:@"<html><body style=\"background-color: #000000; color: #FFFFFF; font-family: Helvetica; font-size: 10pt; width: 300px; word-wrap: break-word;\"></body></html>" baseURL:nil];
m_oDataPresentView.delegate = self;
[self addSubview:m_oDataPresentView];
}
return self;
}
¿Podría mostrarnos el código donde crea una instancia de 'UIWebView' y agregarlo a su vista? – donkim