2011-02-18 30 views
0

我想要在webview中显示图像,但我的问题是我想在ipad和iphone中以不同大小显示相同的图像。 目前在我的项目中我从数据库中获取图像我得到的url.how应该我从iPhone和iPad变化.please帮助 我现在在css中使用此代码我写入大小和附加标签在运行时,但它不recrecre字符串为什么它不会替换我不知道的字符串。如果任何人知道在任何情况下plaese帮助我。如何在Iphone和Ipad中显示不同大小的相同图像

if ([deviceType isEqualToString:@"iPad Simulator"]) 
    { 
     //contentString =[contentString stringByReplacingOccurrencesOfString:@"/>" withString:@"width:\"30%\" height:\"30%\"/>"]; 
     contentString =[contentString stringByReplacingOccurrencesOfString:@"/>" withString:@"class=\"img_ipad\"/>"]; 


    } 
    else 
    { 
     contentString =[contentString stringByReplacingOccurrencesOfString:@"/>" withString:@"width:\"70%\" height:\"70%\"/>"]; 
    } 

回答

0

你应该使用这样的结构:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
     NSLog(@"iPad Idiom"); 
    else 
#else 
     NSLog(@"iPhone Idiom"); 
#endif 
相关问题