我正在使用该方法tableView:indexPathForCell来实现自定义委托,该委托可以UITableViewCell根据其UIWebView内部的框架大小动态调整大小.问题是当我试图找出特定单元格的indexPath是什么时tableView:indexPathForCell返回nil:
- (void)trialSummaryTableViewCell:(TrialSummaryTableViewCell *)cell shouldAssignHeight:(CGFloat)newHeight {
NSIndexPath *indexPath = [tableV indexPathForCell:cell];
NSLog(@"tableV: %@\ncell: %@\nindexPath: %@", tableV, cell, indexPath); //<--
// ...
}
Run Code Online (Sandbox Code Playgroud)
这里,tableV不返回nil,单元格不返回nil,但indexPath返回nil.
我究竟做错了什么?
编辑:我-(void)trialSummaryTableViewCell从该tableView:cellForRowAtIndexPath:方法调用
我有一个.svg图像文件,我想在我的项目中显示.
我尝试使用UIImageView,它适用于.png和.jpg图像格式,但不适用于.svg扩展名.有没有办法使用UIWebView或UIImageView显示.svg图像?
所以我在我的应用程序中有UIWebView,我加载了一些HTML(文章)给它,放一些CSS,使一切更好.这简单明了,一切都很完美,直到我尝试添加景观功能阅读,然后我注意到UIWebView忽略了任何CSS"font-size"我放入HTML并在旋转到横向模式后大幅增加字体大小.
我花了大约4-5个小时(我是编程Iphone应用程序的新手,但是在制作正确的东西时我很顽固)试图修复它.尝试了很多很多配置选项 - 没什么.
今晚发生了一些神奇的事情.看看来源:
景观与虫子:
r = CGRectMake(0.0, 0.0, 480.0, 320.0);
[adView.view removeFromSuperview];
if (!isFullScreen) {
minus = 50 + minus;
[controlsView setFrame:CGRectMake(0, r.size.height - 50, r.size.width, 50)];
} else {
minus = 20;
}
[textView setFrame:CGRectMake(0, 0, r.size.width, r.size.height - minus)];
[scrollView setFrame:CGRectMake(0, 0, r.size.width, r.size.height - minus)];
Run Code Online (Sandbox Code Playgroud)
修复了横向(字体大小不再变化):
r = CGRectMake(0.0, 0.0, 480.0, 320.0);
[adView.view removeFromSuperview];
if (!isFullScreen) {
minus = 50 + minus;
[controlsView setFrame:CGRectMake(0, r.size.height - 50, r.size.width, 50)];
} else {
minus = 20; …Run Code Online (Sandbox Code Playgroud) 我试图通过UIWebView访问一个安全的网站.当我通过safari访问它时,我得到了一个身份验证挑战,但同样的情况并没有出现在应用程序的UIWebView中.我该如何让它出现?
任何指针,示例代码或链接都将非常有用.非常感谢.
如何增加或减少UIWebview字体大小,而不是使用scalePageToFit:NO;
我创建的一个子类UIWebView,并且已经实施了
touchesBegan,touchesMoved和touchesEnded方法.
但是webview子类不处理touch事件.
是否有任何方法来处理UIWebView子类内的触摸事件???
如何从UIWebView中删除渐变 - 如果您过度滚动顶部或底部,则会看到该渐变.这段代码
webView.backgroundColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)
只是改变渐变的颜色,它不会删除它.如何才能做到这一点?
(注意:与UIWebView底层不同的问题)
我希望在我的应用中添加某种"写评论"或"评价我们"功能,以便我的客户可以轻松评价和评论我的应用.
我能想到的最佳做法是在我的应用程序中进行某种弹出或打开UIWebView,这样在打开App Store应用程序时用户就不会被我的应用程序踢掉,如下所示:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myAppName"]];
有谁知道这样做的方法?
我试图使用函数在html页面中调用javascript -
View did load function
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:@"BasicGraph.html"];
NSURL *urlStr = [NSURL fileURLWithPath:writablePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *myPathInfo = [[NSBundle mainBundle] pathForResource:@"BasicGraph" ofType:@"html"];
[fileManager copyItemAtPath:myPathInfo toPath:writablePath error:NULL];
[graphView loadRequest:[NSURLRequest requestWithURL:urlStr]];
}
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
[graphView stringByEvaluatingJavaScriptFromString:@"methodName()"];
}
Run Code Online (Sandbox Code Playgroud)
这是html页面上的javascript -
<script>
function methodName()
{
// code to draw graph
}
Run Code Online (Sandbox Code Playgroud)
但是,函数methodName()没有被调用但是在window.onload = function()之后一切正常.
我正在尝试将RGraphs集成到我的应用程序中,并且Basic.html是编写javascripts的html页面.
如果有人可以帮我解决这个问题会很棒.
我发现,在编译iOS 8(并在iOS 8中运行)时,UIWebView如果在UIWebView模式中呈现的视图控制器中,则无法显示相机/图像选择器.它在视图控制器中直接从窗口"悬挂" rootViewController或从其推出的视图控制器中工作没有问题.
测试应用程序可以在https://dl.dropboxusercontent.com/u/6214425/TestModalWebCamera.zip找到,但我将在下面进行描述.
我的测试应用程序(使用故事板构建,但实际应用程序不使用它们)有两个视图控制器(非原始命名ViewController和ViewController2).ViewController包含在UINavigationController根视图控制器中.ViewController包含一个UIWebView(工作正常),一个"显示"("推")的按钮ViewController2,以及一个UIBarButtonItem模态呈现的按钮ViewController2.ViewController2有另一个UIWebView在"推"时工作但在"提出"时不工作.
双方ViewController并ViewController2装载有:
- (void)viewDidLoad {
[super viewDidLoad];
[self.webView loadHTMLString:@"<input type=\"file\" accept=\"image/*;capture=camera\">" baseURL:nil];
}
Run Code Online (Sandbox Code Playgroud)
当尝试使用模态UIWebViewXcode在控制台中打印以下内容并解除应用模式:
Warning: Attempt to present <UIImagePickerController: 0x150ab800> on <ViewController2: 0x14623580> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
我目前的理论是,在改变UIActionSheet到UIAlertController有可能产生这种情况,但它是非常难以证明.为了以防万一,我将与Apple一起打开雷达.
有人找到了相同的情况和一些解决方法吗?
uiwebview ×10
iphone ×5
ios ×4
cocoa-touch ×2
objective-c ×2
http ×1
ios5 ×1
ios8 ×1
javascript ×1
popup ×1
protocols ×1
rate ×1
review ×1
rgraph ×1
swift ×1
uitableview ×1
webkit ×1