小编Jog*_*Com的帖子

实例已被解除分配,而关键价值观察员仍在其中注册

我有一个UITableView.

在这里,我得到了不同的细胞.每个细胞都有一个模型.使用KVO和NotificationCenter,单元格会监听模型的更改.当我离开ViewController时,我收到此错误:

An instance 0x109564200 of class Model was deallocated while key value observers were still registered with it. 
Observation info was leaked, and may even become mistakenly attached to some other object. 
Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x109429cc0> (
<NSKeyValueObservance 0x109429c50: Observer: 0x10942d1c0, Key path: name, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x10968fa00>
)
Run Code Online (Sandbox Code Playgroud)

在单元格中,我在设置/更改模型属性时执行此操作:

[_model addObserver:self
         forKeyPath:@"name"
            options:0
            context:nil];

[[NSNotificationCenter defaultCenter] addObserver:self …
Run Code Online (Sandbox Code Playgroud)

objective-c nsnotificationcenter ios

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

如何在google map sdk iOS中将路径绘制到另一个地方?

我需要在谷歌地图视图中查找路径到另一个地方.如何使用谷歌地图sdk iOS绘制方向图.

可以任何给出源代码.然后解释如何实现这一目标.

下面我附上图片,我需要使用谷歌地图SDK iOS在iPhone应用程序中实现这一点. 在此输入图像描述

谢谢,

iphone google-maps objective-c google-maps-sdk-ios

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

UILabel没有在iOS8中显示子视图

目前我为背景制作了一个标签,并在UILabel上添加了UIButton.它在iOS 7中显示,但在iOS 8中它没有显示.如果我用UIView替换UILabel那么它工作正常.

如果我使用此代码在iOS 8中使用UILabel用于显示UILabel和子视图UIButton

 UILabel *downLabel = [[UILabel alloc]init];
downLabel.frame    = CGRectMake(0, SCREEN_HEIGHT*0.92, SCREEN_WIDTH,SCREEN_HEIGHT*0.08 );  
[downLabel setBackgroundColor:[UIColor colorWithRed:(66/255.f) green:(67/255.f) blue:(63/255.f)  alpha:1]];
downLabel.userInteractionEnabled = YES;
[self.view addSubview:downLabel];

UIButton *downbtnobj  = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*0.68,downLabel.frame.size.height/10,SCREEN_WIDTH*0.30,downLabel.frame.size.height/1.25)];

UIImage *btndownImage = [UIImage imageNamed:@"img 3.png"];
[downbtnobj setImage:btndownImage forState:UIControlStateNormal];
[downbtnobj addTarget:self action:@selector(bulletInButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[downLabel addSubview:downbtnobj];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

现在您只能看到UILabel正在显示,但UILabel上没有显示按钮.

如果我用UIView取代UILabel那么它就显得很完美了.

    UIView *downLabel = [[UIView alloc]init];
downLabel.frame    = CGRectMake(0, SCREEN_HEIGHT*0.92, SCREEN_WIDTH,SCREEN_HEIGHT*0.08 );
[downLabel setBackgroundColor:[UIColor colorWithRed:(66/255.f) green:(67/255.f) blue:(63/255.f)  alpha:1]];
downLabel.userInteractionEnabled = YES;
[self.view addSubview:downLabel];

 UIButton *downbtnobj  = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*0.68,downLabel.frame.size.height/10,SCREEN_WIDTH*0.30,downLabel.frame.size.height/1.25)];
  UIImage *btndownImage = [UIImage …
Run Code Online (Sandbox Code Playgroud)

objective-c uibutton uilabel ios ios8

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

在parse.com上使用google plus登录ios

我在我的iphone应用程序上通过Google+集成了登录,所有工作都很完美,但我想通过Parse.com登录ios应用程序,

已经使用过这种方法但没有用

[PFUser becomeInBackground:@"session-token-here" block:^(PFUser *user, NSError *error) {
  if (error) {
    // The token could not be validated.
  } else {
    // The current user is now set to user.
  }
}]; 
Run Code Online (Sandbox Code Playgroud)

当我在此发送访问令牌然后得到错误.

 invalid session error. error code =101. 2.refreshToken
Run Code Online (Sandbox Code Playgroud)

请任何人都可以帮我在ios的parse.com上使用google plus登录

iphone login ios google-plus parse-platform

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

dataTaskWithURL doco,做什么:{NSURLErrorDomain,NSURLErrorCancelled}的错误值是什么意思?

假设您正在使用NSURLSession dataTaskWithURL:...

self.currentConnection =
  [sess dataTaskWithURL:goUrl
  completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
    {
    [self.results addObjectsFromArray: [self yourDataConversionCode:data] ];

    dispatch_async(dispatch_get_main_queue(), ^{  if (after) after(); );
    }];
Run Code Online (Sandbox Code Playgroud)

当然,如果可能需要取消它.(比方说,用户已经更改了搜索字词或类似问题.)这很容易...

-(void)cancelAnyCurrentBooksearch
  {
  [self.currentConnection cancel];
  self.currentConnection = nil;
  }
Run Code Online (Sandbox Code Playgroud)

然而,愚蠢地它仍然调用完成块非常烦人.

现在,这是取消的"文档":

/* -cancel returns immediately, but marks a task as being canceled.
 * The task will signal -URLSession:task:didCompleteWithError: with an
 * error value of { NSURLErrorDomain, NSURLErrorCancelled }.
 */
- (void)cancel;
Run Code Online (Sandbox Code Playgroud)

这是问题......

这到底是什么意思:

错误值{NSURLErrorDomain,NSURLErrorCancelled}

你能在NSError中得到两个值吗?

如果是这样,我如何检查NSError是否正是这样:

"{NSURLErrorDomain,NSURLErrorCancelled}"

不管它是什么意思?

请注意,如果您这样做:

self.currentConnection = …
Run Code Online (Sandbox Code Playgroud)

objective-c nserror ios nsurlsession

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

移动到另一个ViewController

我正在使用StoryBoard,我不太确定如何实例化ViewController或如何引用它.

事情是我有两个视图控制器,我有一个按钮.当我从第一个视图控制器按下按钮时,我想转到另一个视图控制器.

我尝试过类似的东西:

let secondViewController:UIViewController = UIViewController()
self.presentViewController(secondViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

有谁知道怎么解释给我?谢谢!

ios swift ios8

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

自定义文本字段

嗨,我想建立一些看起来像图片的东西!

屏幕截图示例 我的问题是文本字段不能是两个部分,并在其中使用微小的图片就像一个图片我想做一些事情就像图片甚至每个文本字段右侧的绿色部分

这就是我想要做的

textfield ios swift3 xcode8.2

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