小编Jef*_*ley的帖子

无法在Mac上使用ARC使用respondsToSelector

当我respondsToSelector在ARC环境中调用时,收到以下错误消息Automatic Reference Counting Issue No known instance method for selector respondsToSelector:

这是标题

#import <AppKit/AppKit.h>


@class MTScrollView;

@protocol MTScrollViewDelegate
-(void)scrollViewDidScroll:(MTScrollView *)scrollView;
@end


@interface MTScrollView : NSScrollView 
{

}

@property(nonatomic, weak) id<MTScrollViewDelegate>delegate;

@end
Run Code Online (Sandbox Code Playgroud)

这是实现文件

#import "MTScrollView.h"

@implementation MTScrollView

@synthesize delegate;


- (void)reflectScrolledClipView:(NSClipView *)aClipView
{
    [super reflectScrolledClipView:aClipView];

    if([delegate respondsToSelector:@selector(scrollViewDidScroll:)])
    {
        [delegate scrollViewDidScroll:self];
    }
}

@end
Run Code Online (Sandbox Code Playgroud)

有关我为什么会收到此错误的任何建议?

macos objective-c automatic-ref-counting

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

从NSString中删除非字母数字字符

我正在寻找一种快速简便的方法来从中删除非字母数字字符NSString.可能是使用了一个东西NSCharacterSet,但我很累,似乎没有任何东西似乎返回一个只包含字符串中的字母数字字符的字符串.

cocoa cocoa-touch nsstring nscharacterset

68
推荐指数
4
解决办法
3万
查看次数

在viewWillDisappear期间隐藏UINavigationController的UIToolbar:

我有一个带有UITableView菜单的iPhone应用程序.选择表中的行时,相应的视图控制器将被推送到应用程序的UINavigationController堆栈中.

我的问题是,MenuViewController它不需要工具栏,但是UIViewControllers它们被推入堆栈中.每个UIViewController那个被推开的呼叫setToolbarHidden:animated:viewDidAppear:.要隐藏工具栏,我呼吁setToolbarHidden:animated:viewWillDisappear:.

显示工具栏的工作方式,以便当推出的视图出现时,工具栏向上滑动并且视图正确调整大小.但是,按下后退按钮时,工具栏会向下滑动,但视图不会调整大小.这意味着当另一个视图过渡时,沿着视图底部有一个黑色条带.我已经尝试在隐藏工具栏之前将工具栏的高度添加到视图的高度,但是这会导致视图在转换,以便仍然有一个黑条.

我意识到我可以管理自己的UIToolbar,但UINavigationControllers为了方便起见,我想使用内置的UIToolbar.

这个论坛帖子提到了同样的问题,但没有提到解决方法.

iphone cocoa-touch uitoolbar uikit uinavigationcontroller

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

访问库中的Burst Mode照片

我正在尝试访问用户使用突发模式拍摄的iOS资源库中的照片.我正在尝试使用ALAssetsLibrary和过滤照片:

- (void)findBurstModePhotos
{
    ALAssetsFilter *allPhotos = [ALAssetsFilter allPhotos];

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];

    [assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll
                                usingBlock:^(ALAssetsGroup *group,
                                             BOOL *stop) {
                                    [group setAssetsFilter:allPhotos];

                                    NSLog(@"Group: %@",
                                          [group valueForProperty:
                                           ALAssetsGroupPropertyName]);

                                    if ([group numberOfAssets] > 0) {
                                        [self evaluateGroup:group];
                                    }
                                }
                              failureBlock:^(NSError *error) {
                                  NSLog(@"Failure enumerating groups: %@",
                                        [error localizedDescription]);
                              }];
}

- (void)evaluateGroup:(ALAssetsGroup *)group
{
    [group enumerateAssetsUsingBlock:^(ALAsset *result,
                                       NSUInteger index,
                                       BOOL *stop) {
        NSLog(@"Photo date: %@", [result valueForProperty:ALAssetPropertyDate]);
    }];
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,这会将Burst Mode照片作为单张照片返回.是否有支持的方式单独获取Burst Mode照片?我想从单个突发模式会话中获取每张照片.

ios alasset alassetslibrary alassetsgroup

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

旋转后获得iPad屏幕键盘的大小

对于我正在为iPad设计的应用程序,我有一个滚动视图,其中包含一些文本字段/文本视图.为了保持一切可见,我调整了contentSize滚动视图属性以在底部添加一个缓冲区,该缓冲区对应于键盘与滚动视图重叠的程度.这是代码(这里有一些特定于应用程序的东西,但希望不是那么多,你无法理解它):

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}


- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc removeObserver:self name:nil object:nil];
}

- (void)keyboardWillShow:(NSNotification *)aNotification
{
    NSValue *animationCurve = [[aNotification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey];
    UIViewAnimationCurve curve;
    [animationCurve getValue:&curve];

    NSValue *animationDuration = [[aNotification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval duration;
    [animationDuration getValue:&duration];

    NSValue *endingFrame = [[aNotification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect frame;
    [endingFrame getValue:&frame];

    [UIView beginAnimations:@"keyboardWillShow" context:bodyView];
    [UIView setAnimationCurve:curve];
    [UIView setAnimationDuration:duration]; …
Run Code Online (Sandbox Code Playgroud)

uikeyboard ipad ios

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

任何代码示例显示如何在objC中求解多个线性方程?

是否存在如何解决矩阵的代码示例,例如iPhone平台上的矩阵.实际上,真实矩阵要大得多(大约100个变量).由于它是简单的线性代数,我不能认为代码是那么复杂,我也听说过数学库包和LAPACK,但是找不到它们实现的任何例子.

如果有人知道有关如何从创建矩阵到解决每个变量的任何示例或教程,那么非常感谢非常感谢.

 ____            ____
|                    |
|  4   3  -1   |  2  |
| -2   3   8   |  0  |
|  0   2   6   | -1  |
|____            ____|
Run Code Online (Sandbox Code Playgroud)

math objective-c linear-algebra

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

NSArray中的对象数

我想知道是否有任何可能的方法来获取NSArray对象中对象的数量(计数)

iphone objective-c nsarray

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

对C IDE的建议?

我曾经在我的unix机器上使用gcc编译器.我现在被迫在Windows机器上工作.是否有任何很酷的IDE或简单的C编辑器与unix终端像感觉(Black Screen and colored syntax在它:))

还有哪些编辑器/ IDE和windows的gcc一样健壮?您个人最喜欢的是什么?在我坚持使用之前,我想试试其中一些.

谢谢.

c c++ windows ide

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

我可以设置UILabel来扩展以适应任意数量的文本吗?

此问题更多用于开发目的,绝不会用于运送应用.我需要做一个快速而又脏的UILabel,其文本字段我可以指向一个非常非常长的字符串.真的很长 我非常喜欢IB,无法弄清楚正确的魔术握手,让UILabel气球到一个非常大的尺寸.有没有人有任何想法?

干杯,道格

iphone cocoa-touch interface-builder uilabel

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

可可和Objective-C中的哈希

我正在为Mac编写应用程序.我需要一些从字符串生成哈希的代码.我需要创建这些哈希:

  • MD2
  • MD4
  • MD5
  • SHA-0
  • SHA-1

我怎样才能做到这一点?谢谢.

c hash cocoa openssl objective-c

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

无法将两个NSStrings设置为一个UITextView

我想得到

NSString * test1 = @"one";
 NSString * test2 = @"two";
Run Code Online (Sandbox Code Playgroud)

到我的UITextView.我写了这个:

  uitextview.text = (@"%@, %@",test1, test2 );
Run Code Online (Sandbox Code Playgroud)

但是UITextView只获得第二个NSString ...为什么?

iphone cocoa-touch objective-c nsstring

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

在类和appDelegate中的同一个类中导入appDelegate的后果

我想知道在类和appDelegate中的同一个类中导入appDelegate的后果.因为,我在我的应用程序中成功完成了这项工作,但建议不要这样做.尽管进行了大量的搜索,但我找不到答案.

提前致谢.

iphone cocoa-touch header uiapplicationdelegate

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

在iOS上使用嵌入式YouTube视频进行媒体回调

我正在将UIWebViewiOS 视频嵌入到iOS应用中.我在YouTube博客文章中使用"方法2" 来嵌入视频.这很有效,除了因为iOS管理媒体播放器,我无法确定视频是播放还是已完成.在播放视频时,我不想将该视图与另一视图交换,但我认为没有一种好方法可以确定.有任何想法吗?如果有办法获得JavaScript回调,那将会有效,或者如果有办法使用HTML5 <video>标签嵌入YouTube视频,那么这也会有效(我已经尝试过但没有取得成功).

youtube cocoa-touch uiwebview ios

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