小编pya*_*eld的帖子

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

为什么UITableView的滑动删除有时工作正常,有时不行?

有一个UITableView关于我的看法,我想申请一个特定部分的触击删除模式的行.我实施的内容如下:

 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@">> canEditRowAtIndexPath");
    if (indexPath.section == CanDeletedSection) {
        return YES;
    }else{
        return NO;
    }
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@">> editingStyleForRowAtIndexPath");
    if (indexPath.section == CanDeletedSection) {
        return UITableViewCellEditingStyleDelete;
    }
    return UITableViewCellEditingStyleNone;
}
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
     NSLog(@">> commitEditingStyle");
     if (editingStyle == UITableViewCellEditingStyleDelete) {
         // dosomething
     }
}
Run Code Online (Sandbox Code Playgroud)

但是当我滑动表格行时,有时Delete按钮会出现,有时则不会.顺便说一句,我的单元格是自定义的并且继承自UITableViewCell.

我已经添加了NSLog上述方法.当Delete按钮没有出现时,我得到的日志如下:

>> editingStyleForRowAtIndexPath
>> canEditRowAtIndexPath
Run Code Online (Sandbox Code Playgroud)

出现Delete按钮时,日志如下:

>> editingStyleForRowAtIndexPath
>> …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview swipe ios

4
推荐指数
2
解决办法
4726
查看次数

AFHTTPRequestOperationManager获取请求失败,错误域= AFNetworkingErrorDomain代码= -1016

我发送一个GET请求到这个URL: https://test.com/app/login?json={"user":"test@gmail.com","password":"test"}

但是返回此错误:

Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo=0x9ad3520 {NSErrorFailingURLKey=https://test.com/app/login?json=%7B%22user%22:%22test@gmail.com%22,%22password%22:%22test%22%7D, AFNetworkingOperationFailingURLResponseErrorKey= { URL: https://test.com/app/login?json=%7B%22user%22:%22test@gmail.com%22,%22password%22:%22test%22%7D } { status code: 200, 

    headers {
    "Cache-Control" = "max-age=900";
    Connection = "Keep-Alive";
    "Content-Length" = 6116;
    "Content-Type" = "text/plain; charset=UTF-8";
    Date = "Wed, 15 Jan 2014 09:14:22 GMT";
    Expires = "Wed, 15 Jan 2014 09:29:22 GMT";
    "Keep-Alive" = "timeout=2, max=100";
    Server = "Apache-Coyote/1.1";
    "Set-Cookie" = "APP-SESSION-ID=xxxxxxxxxxxxxxxx; Path=/app/; HttpOnly, APP-ROUTE-ID=.app1_node2; path=/, API-ROUTE-ID=.app1_node2; path=/";
    } }

, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain}
Run Code Online (Sandbox Code Playgroud)

这是我的代码,我使用NSUTF8StringEncoding添加了百分比转义.

manager = …
Run Code Online (Sandbox Code Playgroud)

ios afnetworking-2

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

标签 统计

ios ×2

afnetworking-2 ×1

class ×1

iphone ×1

swift ×1

swipe ×1

uitableview ×1