小编adi*_*dit的帖子

加载从故事板中实例化的nib文件

所以我对这个故事板概念很新.我有一个视图nibs放入故事板,每个对应一个UIViewController子类,我尝试使用以下代码加载nib文件:

TestViewController *vc = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
    [self.view setBackgroundColor:[UIColor blueColor]];
    [self.view setFrame:CGRectMake(0, self.profilePicture_.frameHeight + self.profilePicture_.frameY + 10, self.scrollView_.frameWidth, 100)];
    [self.view addSubview:vc.view];
Run Code Online (Sandbox Code Playgroud)

但是,它给了我以下错误:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/aditya15417/Library/Application Support/iPhone Simulator/5.1/Applications/64E6CEC9-E6DC-4AF5-BF16-11BFB6415BDC/Pulse.app> (loaded)' with name 'TestViewController''
Run Code Online (Sandbox Code Playgroud)

所以问题是,如果我在故事板中有我的笔尖是不可能使用initWithNibName?如果有办法,我该怎么做?

iphone objective-c ipad ios

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

convertRect在超级视图中获取相对位置

我有一堆水平UITableView放在UIViewController1中.我想找到被点击的UITableViewCell的位置,我想根据UIViewController1得到位置.所以这就是我在didSelectRowAtIndexPath中所做的:

MyCell *cell = (MyCell *)[tableView cellForRowAtIndexPath:indexPath];

                UIView *animatedView = [[UIView alloc] initWithFrame:cell.frame];
 [animatedView setFrame:[animatedView convertRect:animatedView.frame toView:self.newsRackController.view]];
Run Code Online (Sandbox Code Playgroud)

但是,似乎这不能正确转换它.我究竟做错了什么?

iphone objective-c uiview ipad ios

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

autocapital单词在UITextField中不起作用

我有以下代码使第一个字母变为粗体:

  self.firstNameTexField_.autocapitalizationType = UITextAutocapitalizationTypeWords;
    self.lastNameTextField_.autocapitalizationType = UITextAutocapitalizationTypeWords;
    self.emailTextField_.autocapitalizationType = UITextAutocapitalizationTypeWords;
Run Code Online (Sandbox Code Playgroud)

但是,这并不是首字母的第一个字母.知道为什么吗?

objective-c ios

3
推荐指数
2
解决办法
4425
查看次数

获取经过身份验证的用户 onAuthenticationSuccess

我有以下身份验证处理程序:

class LoginAuthSuccessHandler implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface
{
    private $router;
    private $container;

    /**
    * Constructor
    * @param RouterInterface   $router
    */
    public function __construct(RouterInterface $router, $container)
    {
        $this->router = $router;
        $this->container = $container;
    }

    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        if ($request->isXmlHttpRequest()) {
            $user =  $this->container->get('security.context')->getToken()->getUser();
            $result = array('success' => true, 'user' => $user);
            return new Response(json_encode($result));
        } else {
            $route = $this->router->generate('ShopiousMainBundle_profile');

            $referrer_url = $request->server->get('HTTP_REFERER');
            if (strstr($referrer_url, '/items/')) {
                 $route = $referrer_url;
            }

            return new RedirectResponse($route);
        }
    }

    public function …
Run Code Online (Sandbox Code Playgroud)

php symfony php-5.3 fosuserbundle

3
推荐指数
2
解决办法
2965
查看次数

UIImageView中的圆角

我有以下代码:

[avatar.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[avatar.layer setBorderWidth:2.0];
[avatar.layer setShadowOffset:CGSizeMake(-1.0, -1.0)];
[avatar.layer setCornerRadius:8];
Run Code Online (Sandbox Code Playgroud)

它确实给我一个围绕UIImage的圆形白色边框,但是在4个角落周围还有额外的尖端..有没有办法将它切掉?

在此输入图像描述

iphone objective-c uiimageview

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

将字符数组添加到 HashSet

我有一个 HashSet 字符,我正在尝试做:

Collections.addAll(mySet, test.toCharArray());
        mySet.addAll(test.toCharArray());
Run Code Online (Sandbox Code Playgroud)

为什么说它不适用?我该如何解决?

java

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

警告:在两个SDK中都实现了类

运行我的应用程序时出现以下错误:

objc [59714]:类消息在/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/PrivateFrameworks/MIME.framework/MIME和/ Users/aditya15417/Library/Application中实现支持/ iPhone模拟器/ 4.3.2 /应用程序/ 4EFD7570-AD87-48E8-8606-1D5633F65AD9/CTest.app/CTest.将使用两者之一.哪一个未定义.

为什么是这样?我该如何解决这个问题?

iphone objective-c ipad

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

在initWithFrame之前调用viewDidLoad?

我有一个自定义init方法:

- (id) initWithFrame:(CGRect ) frame andImage:(UIImage *) image
{
    self = [super init];
    if (self){
        self.view.frame = frame;
        self.imageView_.image = image;
        self.imageScrollView_.frame = self.view.frame;
        imageOriginalFrame = frame;
        zoomedImageFrame = frame;
         NSLog(@"SCREEN DIM %f AND %f", zoomedImageFrame.size.height, zoomedImageFrame.origin.y);
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

这是我如何呈现它:

FullSizeImageViewController * fullSize = [[FullSizeImageViewController alloc] initWithFrame:imageOriginalFrame andImage:image];
                    if ([self.delegate respondsToSelector:@selector(fullStoryViewController:presentModalViewController:animated:)]) {
                        [self.delegate fullStoryViewController:self presentModalViewController:fullSize animated:YES];
                    }
Run Code Online (Sandbox Code Playgroud)

但是,令人惊讶的是我的viewDidLoad在initWithFrame之前被调用.这怎么可能?

我猜这是因为我打电话给超级初始化?如果不是我该怎么做?

iphone objective-c ipad ios

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

导航栏中的左栏按钮项目

在iOS5中,我们将leftBarButtonItems设置为导航栏,如何在iOS 5之前执行此操作?我基本上有一个UIBarButtonItem数组,我想把它设置为.

iphone objective-c ipad ios

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

AFNetworking UIImageView setImageWithURLRequest返回响应代码0

我正在使用AFNetworking的UIImageView类别,我在响应代码状态中不断收到响应代码0.知道为什么会这样吗?我是这样做的:

[self.newsPicture_ setImageWithURLRequest:storyImageRequest 
                                         placeholderImage:nil 
                                                  success:^(NSURLRequest * request, NSHTTPURLResponse * response, UIImage * image) {
                                                      if ([response statusCode] == 200){
                                                          dispatch_async(dispatch_get_main_queue(), ^(void){

 });
                                                      } else {
                                                          NSLog(@"RESPONSE ERROR WITH CODE IS %d", [response statusCode]);
                                                      }
                                                  }failure:^(NSURLRequest * request, NSHTTPURLResponse * response, NSError * error){
                                                      if (error){
                                                          NSLog(@"Error in requesting news story image");
                                                      }
                                                  }];
Run Code Online (Sandbox Code Playgroud)

知道为什么会这样吗?

这只发生在我使用基于块的函数调用时.

当我使用setImageWithURL时,一切正常

iphone objective-c ipad ios afnetworking

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