小编Rea*_*omp的帖子

WKWebView估计进度

我正试图Estimated Progress在我的实施,WKWebView但似乎无法搞清楚.你能帮我吗?

这是我得到的:

self.view = self.webView;

NSURL *url = [NSURL URLWithString:stringWeb];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];

self.webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];

[self.webView loadRequest:request];
Run Code Online (Sandbox Code Playgroud)

我看到这个答案得到了一点,但这对于一个微调器来说:带有进度条的UIWebView

而且Apple的文档是某种形式的estimatedProgress(我假设它的导航栏正下方显示了蓝色条形图,显示了Safari中的进度),但我一般不会看到如何实现它:https://developer.apple.com /库/ IOS /文档/ WebKit的/参考/ WKWebView_Ref /#// apple_ref/OCC/instp/WKWebView/estimatedProgress

所以我被困在这里.任何帮助将不胜感激,谢谢!

更新:这就是我现在所拥有的.因为看起来我的进度视图和WKWebView加载了两次而导致崩溃,我不确定为什么会这样.获得需要删除观察者的错误.这是我的代码,因为它代表 -

ViewController.h

@interface WebPageViewController : UIViewController <UIWebViewDelegate>
@property (strong, nonatomic) NSString *stringMobile;
@property (strong, nonatomic) NSString *stringWeb;
@property (strong, nonatomic) IBOutlet UIView *view;
@property (nonatomic, strong) WKWebView …
Run Code Online (Sandbox Code Playgroud)

uiwebview webview ios wkwebview

17
推荐指数
2
解决办法
2万
查看次数

使用API​​,RestKit 0.20嵌套对象映射问题

我得到了titleForHeaderInSection正确的,它拉动了leaf.

但什么都没有themes.

我猜测我的映射themes不起作用,因为cellForRowForIndexPath当我设置断点时似乎没有被调用.

但显然我不确定,这就是为什么我在寻找一些指导.谢谢!

API JSON

{
    "springs": [{
        "name": "baskets",
        "leafs": [{
            "name": "New Season",
            "abbreviation": "nb",
            "themes": [{
                "name": "Hops",
                "abbreviation": "HS",
}          
Run Code Online (Sandbox Code Playgroud)

ViewController.h

@property (strong, nonatomic) NSArray *springs;
@property (strong, nonatomic) NSMutableArray *leafs;
@property (strong, nonatomic) NSMutableArray *themes;
Run Code Online (Sandbox Code Playgroud)

api tableview ios restkit

7
推荐指数
1
解决办法
487
查看次数

AutoLayout标签在屏幕右侧被切断

我正在尝试在我的应用程序中使用自动布局来自定义表视图单元格.

我似乎无法正确地得到约束.

我将标签放在自定义表视图单元格中,但标签仍然被切断.有任何想法吗?

谢谢!将发布任何其他需要.试图在下面显示所需的信息:

在Xcode中调试.不知何故,模拟器中显示的内容与Xcode调试中的不同.

这是我显示的TableView的宽度: 在此输入图像描述

更新: 这里的问题与用户亚马在接受的答案中所说的有关,但我想让问答更加清晰,因为我已经找到了其他遇到此问题的人.

在他最初的评论中,他提到了Xcode View调试,这非常棒,而且我能够进一步深入研究.它被称为辅助编辑器:设备预览,您可以在其中查看屏幕上的内容的布局和图层,以查看是否有标签重叠或根据其运行的设备离开屏幕.如果要检查多个设备大小,只需点击此图片左下角的加号图标即可. 在此输入图像描述

这有助于我找到与TableView重叠的层和大小调整问题.我能够看到它在每个设备尺寸上的样子.

有时候使用Pin菜单也有帮助.有时标签可以在屏幕外运行,因为它不知道单元格的约束取决于设备大小.因此,如果标签基于横向布局,但您的标签可以在屏幕外运行,但设备是iPhone 5,例如在肖像中.这是Pin菜单:

在此输入图像描述

希望有意义并为问题提供更多颜色.如果您有任何问题,请告诉我,感谢大家的帮助!

storyboard uitableview ios xcode6

7
推荐指数
1
解决办法
9012
查看次数

图像未在表视图中立即加载

我正在使用SDWebImage和抓取与新闻API中的新闻文章相关联的图像.

问题是,在我开始滚动之前,屏幕上的单元格图像没有加载UITableView.一旦我滚过一个单元格,它就会离开屏幕,一旦我回到它,最终会加载Image.

这是我的(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath代码:

if ([feedLocal.images count] == 0) {
    [cell.imageView setImage:[UIImage imageNamed:@"e.png"]];
}
else {    
    Images *imageLocal = [feedLocal.images objectAtIndex:0];
    NSString *imageURL = [NSString stringWithFormat:@"%@", imageLocal.url];
    NSLog(@"img url: %@", imageURL);

    // Here we use the new provided setImageWithURL: method to load the web image
    __weak UITableViewCell *wcell = cell;
    [cell.imageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", imageURL]]
                   placeholderImage:[UIImage imageNamed:@"115_64.png"]
                          completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                              if(image == nil) {
                                  [wcell.imageView setImage:[UIImage …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios sdwebimage

6
推荐指数
2
解决办法
7973
查看次数

"objectAtIndex"的NSUserDefaults错误

在这行代码上获取错误消息:

Team *team = [leagueLocal.teams objectAtIndex:indexpath.row];
Run Code Online (Sandbox Code Playgroud)

错误是"使用未声明的标识符'indexpath'"...但我不确定我会在objectAtIndex上放什么:除了indexpath.row,因为这对我来说在这个应用程序的TableView部分中有用.

大图,我正在尝试使用NSUserDefaults保存所选的团队名称.团队名称通过JSON从Web服务中提取.

这是我到目前为止NSUserDefaults部分的完整代码:

   // Create User Defaults Variable
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

   // Tell it where to look
Sport *sportLocal = [sports objectAtIndex:0];
League *leagueLocal = [sportLocal.leagues objectAtIndex:0];
Team *team = [leagueLocal.teams objectAtIndex:indexpath.row];  //  This is where error is

   // Store the data, this is the stuff I want to save
[defaults setObject:team.abbreviation forKey:[NSString stringWithFormat:@"teamAbbreviation%d", _buttonNumber]];

   // After saving, synchronize data
[defaults synchronize];
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!如果需要更多信息,或者我可以帮助澄清是否需要,请告诉我.

编辑 …

arrays objective-c nsuserdefaults

3
推荐指数
1
解决办法
239
查看次数

将2个数组合并为一个数组

我正在使用RestKit获得2个独立API的.我得到的API只是罚款,但我需要把二者结合起来arrays转换一个array.

我该怎么做?这是我的代码,将根据需要发布额外的内容,谢谢! (NSMutableArray *arrayarray这将是组合hArrayiArray)

ViewController.m

@property (strong, nonatomic) NSArray *hArray;
@property (strong, nonatomic) NSMutableArray *array;
@property (strong, nonatomic) NSArray *iArray;


[[RKObjectManager sharedManager] loadObjectsAtResourcePath:
[NSString stringWithFormat:@"/n/?limit=200&l=%@&t=%@&apikey=111", 
lAbbreviation, tID] usingBlock:^(RKObjectLoader *loader) {
        loader.onDidLoadObjects = ^(NSArray *objects){
            hArray = objects;
            [_tableView reloadData];
        };
        [loader.mappingProvider setMapping:[F mapping] forKeyPath:@"f"];
        loader.onDidLoadResponse = ^(RKResponse *response){
        };
    }];

    [self.iObjectManager loadObjectsAtResourcePath:
    [NSString stringWithFormat:@"/u/?client_id=111"] 
    usingBlock:^(RKObjectLoader *loader) {
        loader.onDidLoadObjects = ^(NSArray *oI){
            iArray = …
Run Code Online (Sandbox Code Playgroud)

arrays objective-c ios restkit

1
推荐指数
1
解决办法
3608
查看次数