小编Ser*_*nce的帖子

将手势识别器/操作方法附加到视图会违反模型视图控制器吗?

想要问人们对此的看法.我有一个uiimageview子类,在它的初始化器中我向imageview添加了一些手势识别器,我还在课堂中包含了手势识别器委托方法.我的问题是,这是否违反了模型视图控制器?是否所有与控制视图有关的代码都在视图控制器中?与此相同,在视图中放置按钮操作方法.无论如何,有兴趣听取意见.

iphone model-view-controller cocoa-touch objective-c ios

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

如何找到包含给定字符的字体?

我有一个字体,我用于我的应用程序,只使用英文字符.我CoreText用来显示文本,我注意到每当有人输入一个未包含在字体中的字符(如阿拉伯字符),程序就会挂起这一行:

CTFramesetterCreateFrame(textFramesetter, CFRangeMake(0, 0), textMutablePath, NULL); 
Run Code Online (Sandbox Code Playgroud)

我有一些问题:

  1. 是否可以知道字体中是否包含某个字符?
  2. 系统是否可以找到包含未知字符的字体?

相关:检查UIFont是否支持某些字符

iphone cocoa-touch objective-c ios

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

安装OpenSSL Cocoapod时遇到问题

我正在尝试在Xcode 9.4中安装OpenSSL Cocoapod,并且得到以下信息:

[!] / bin / bash -c set -e VERSION =“ 1.0.2h” SDKVERSION =xcrun --sdk iphoneos --show-sdk-version 2> /dev/null MIN_SDK_VERSION_FLAG =“-miphoneos-version-min = 7.0”

BASEPATH =“ $ {PWD}” CURRENTPATH =“ / tmp / openssl” ARCHS =“ i386 x86_64 armv7 armv7s arm64” DEVELOPER =xcode-select -print-path

mkdir -p“ $ {CURRENTPATH}” mkdir -p“ $ {CURRENTPATH} / bin”

cp“ file.tgz”“ $ {CURRENTPATH} /file.tgz” cd“ $ {CURRENTPATH}” tar -xzf file.tgz cd“ openssl-$ {VERSION}”

$ {ARCHS}中用于ARCH的CONFIGURE_FOR =“ iphoneos-cross”

如果[“ $ {ARCH}” ==“ i386”] …

xcode openssl cocoapods

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

子类化UIWindow

我只是试图将UIWindow子类化,以便可以拦截一些通知。除了下面列出的代码,我还进入MainWindow.xib并将UIWindow对象更新为我的子类。它可以很好地加载,问题是我的标签栏上的标签没有响应(在下面的示例中,我仅添加了一个标签,但是在我的应用中,我有多个标签(不是问题))。谁能看到我可能做错了什么?谢谢。

UISubclassedWindow.h

#import <UIKit/UIKit.h>

@interface UISubclassedWindow : UIWindow 
{

}

@end
Run Code Online (Sandbox Code Playgroud)

UISubclassedWindow.m

    #import "UISubclassedWindow.h"

    @implementation UISubclassedWindow

- (id) initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        NSLog(@"init");
    }
    return self;
}

    - (void)makeKeyAndVisible
    {
        [super makeKeyAndVisible];
        NSLog(@"makeKeyAndVisible");
    }

    - (void)becomeKeyWindow
    {
        [super becomeKeyWindow];
        NSLog(@"becomeKeyWindow");

    }

    - (void)makeKeyWindow
    {
        [super makeKeyWindow];
        NSLog(@"makekeyWindow");
    }

    - (void)sendEvent:(UIEvent *)event
    {
    }

    - (void)dealloc 
    {
        [super dealloc];
    }

    @end
Run Code Online (Sandbox Code Playgroud)

AppDelegate.h

进口

@class UISubclassedWindow;

@interface My_AppAppDelegate : NSObject <UIApplicationDelegate> 
{
    UISubclassedWindow *window;
}

@property (nonatomic, …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uiviewcontroller ios

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

setContentOffset失去精度?

我有一个应用程序,我需要初始化contentOffsetUIScrollView,以一定的价值.我注意到当我设置contentOffset它时,它将点向上舍入到最接近的整数.我尝试过使用两者setContentOffset并且setContentOffset:animated仍然得到相同的结果.当我尝试手动添加contentOffset到帧原点时,我没有得到我想要的结果.任何人都知道这个吗?

UIScrollView *myScrollViewTemp = [[UIScrollView alloc] initWithFrame: CGRectMake(CropThePhotoViewControllerScrollViewBorderWidth, CropThePhotoViewControllerScrollViewBorderWidth, self.myScrollViewBorderView.frame.size.width - (CropThePhotoViewControllerScrollViewBorderWidth * 2), self.myScrollViewBorderView.frame.size.height - (CropThePhotoViewControllerScrollViewBorderWidth * 2))];
[self setMyScrollView: myScrollViewTemp];
[[self myScrollView] setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[[self myScrollView] setShowsVerticalScrollIndicator: NO];
[[self myScrollView] setShowsHorizontalScrollIndicator: NO];
[[self myScrollView] setBouncesZoom: YES];
[[self myScrollView] setDecelerationRate: UIScrollViewDecelerationRateFast];
[[self myScrollView] setDelegate:self];
[[self myScrollViewBorderView] addSubview: [self myScrollView]];
[myScrollViewTemp release];

UIImageView *myImageViewTemp = [[UIImageView alloc] initWithImage: self.myImage];
[self setMyImageView: myImageViewTemp];
[[self myScrollView] addSubview:[self myImageView]]; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uiscrollview ios

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

为什么当视图子视图被触摸时,hitTest 没有被调用?

我有一个我称之为的视图,parentView它有一个名为 的子视图childView。的一部分childView在 的范围之外parentViewchildView并附有panGestureRecognizer。我已经实现了以下内容,以便即使超出其超级视图范围,parentView它也能识别触摸:childView

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    if (!self.clipsToBounds && !self.hidden && self.alpha > 0)
    {
        for (UIView *subview in self.subviews)
        {
            CGPoint subPoint = [subview convertPoint:point fromView:self];
            UIView *result = [subview hitTest:subPoint withEvent:event];
            if (result != nil)
            {
                return result;
                break;
            }
        }
    }

    return [super hitTest:point withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)

然而当我触摸或拖动时childViewhitTest却根本不被调用了parentView。为什么是这样?

iphone cocoa-touch uiview hittest ios

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

GPUImage:使用或不使用smoothScaleOutput

我正在使用GPUImage我的应用程序中的过滤器(使用它将一个值过滤器应用于静态照片).我正在尝试决定是否需要使用smoothlyScaleOutput.它的缺点是加载大型照片需要很长时间.我读过Brad Larson说:

照片的smoothScaleOutput:选项告诉框架在对照片进行下采样时使用三线性过滤.也就是说,对于缩小的大型照片,它会产生更平滑的输出.如果您不需要缩小照片,可以将其关闭以获得更好的性能和更清晰的照片.

只是很好奇,但对于那些GPUImage以与我相同的方式使用的人来说,启用此选项对我来说是否值得?我很难区分它,但我只使用一些基本滤镜(亮度,对比度,棕褐色等)对少量照片进行采样.

关于什么可能构成缩小照片也很困惑.这是否意味着使用UIImage drawInRect以较小的分辨率绘制照片?或者这是否意味着拍摄大照片并将其大小转换为适合UIImageView?或两者?

任何帮助将不胜感激.

iphone ios gpuimage

5
推荐指数
0
解决办法
486
查看次数

在CoreData中存储NSMutableAttributedString的简单方法

我正在尝试存储一个NSMutableAttributedStringin CoreData,但由于我NSMutableAttributedString包含无法存档的Core Foundation对象的某些属性而遇到问题.是否有一种简单的方法可以将此对象存储在CoreData中而无需手动执行某些杂乱的操作?

iphone cocoa-touch core-data ios

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

如何在沙盒中测试免费试用版?

I have a one year auto-renewable subscription in my app with a three day free trial. According to Apple, while testing in the sandbox, a one year subscription is equivalent to one hour but it says nothing about how long the free trial is. Add to this, when I'm testing and I sign-up for the free trial, the receipt doesn't list a separate transaction for a free trial, it simply lists the first hour long subscription:

transactionIdentifier: 1000000408088544
purchaseDate: Sat …

testing storekit in-app-purchase ios receipt-validation

5
推荐指数
0
解决办法
611
查看次数

在 App Store Connect 中,应用程序预览海报框架未保存

我在 App Store Connect 上为我的应用程序添加了一些视频应用程序预览,当我设置视频海报框架时,它永远不会保存我想要的图像,它总是恢复到 Apple 默认的初始图像。有谁知道解决办法吗?

更新:我确实联系了 App Store Connect,他们告诉我这是最近的一个错误,他们正在积极修复。下周初我将与他们联系。

app-preview app-store-connect

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