我有一个图像墙(UIScrollView),在那里我有很多UIImageView's.
这是我的代码:
for (ThumbPosterModel *tPoster in _thumbsPosterStack) {
UIImageView *imageView = [[UIImageView alloc] initWithImage:tPoster.thumb];
imageView.userInteractionEnabled = YES;
imageView.frame = CGRectMake(i, imageView.frame.origin.y, imageView.frame.size.width, imageView.frame.size.height);
[tPoster setTag:tag];
[_posterTagArr addObject:(BasicPosterModel*)tPoster];
imageView.tag = tag;
tag++;
[posterWallScrollView addSubview:imageView];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageDoubleTapped:)];
doubleTap.numberOfTapsRequired = 2;
[imageView addGestureRecognizer:doubleTap];
}
Run Code Online (Sandbox Code Playgroud)
这是我的IBAction:
-(IBAction)imageDoubleTapped:(id)sender {
NSInteger selectTag = (((UIGestureRecognizer*)sender).view.tag);
for (BasicPosterModel *bPoster in _posterTagArr) {
if(bPoster.tag == selectTag) {
[UIView transitionFromView:(UIImageView*)((UIGestureRecognizer*)sender).view
toView:mySecordView //let's say next ImageView. Doesn't matter
duration:1.0
options:UIViewAnimationOptionTransitionCrossDissolve
completion:^(BOOL finished) …Run Code Online (Sandbox Code Playgroud) objective-c uiviewanimation uiviewanimationtransition ios uiviewanimation-curve
我在看这个例子http://teragonaudio.com/article/How-to-do-realtime-recording-with-effect-processing-on-iOS.html
我想关闭我的输出.我试图改变:kAudioSessionCategory_PlayAndRecord对kAudioSessionCategory_RecordAudio,但是这是行不通的.我也试图摆脱:
if(AudioUnitSetProperty(*audioUnit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &streamDescription, sizeof(streamDescription)) != noErr) {
return 1;
}
Run Code Online (Sandbox Code Playgroud)
Becouse我想从麦克风那里获得声音但不能播放它.但是当我的声音达到renderCallback方法时,无论我做什么都有-50错误.当音频在输出上自动播放时,一切正常......
使用代码更新:
using namespace std;
AudioUnit *audioUnit = NULL;
float *convertedSampleBuffer = NULL;
int initAudioSession() {
audioUnit = (AudioUnit*)malloc(sizeof(AudioUnit));
if(AudioSessionInitialize(NULL, NULL, NULL, NULL) != noErr) {
return 1;
}
if(AudioSessionSetActive(true) != noErr) {
return 1;
}
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
if(AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
sizeof(UInt32), &sessionCategory) != noErr) {
return 1;
}
Float32 bufferSizeInSec = 0.02f;
if(AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration,
sizeof(Float32), &bufferSizeInSec) != noErr) {
return 1; …Run Code Online (Sandbox Code Playgroud) 我想在项目中添加虚拟对象以进行测试,但我不希望它们包含在我的最终构建中.所以我有我的AppDelegate班级和进口:
#ifdef TESTING
#import "DummyBeaconLocationManager.h"
#else
#import "BeaconLocationManager.h"
#endif
Run Code Online (Sandbox Code Playgroud)
然后:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
#ifdef TESTING
[[DummyBeaconLocationManager sharedInstance] startRanging];
#else
self.beaconLocationManager = [BeaconLocationManager sharedInstance];
[self.beaconLocationManager startRanging];
#endif
return YES;
}
Run Code Online (Sandbox Code Playgroud)
但问题是我必须将此包含在我的Target Membership,而不是我的测试目标中.有没有办法不在我的主目标中包含这些文件,但仅限于Test目标?
编辑:需要做的是在发布后测试我的应用程序.我想在模拟器上测试它,但是使用信标的app.所以我创建了代表信标的虚拟对象并模拟了位置管理器.当应用程序以TESTING选项启动时,它不会启动测距信标,而是将虚拟对象作为信标.
我有2个应用程序:免费和完整我有2种语言:英语和德语
这导致4个不同的应用程序名称
我怎样才能做到这一点.
实际上我的所有目标都有"Free"这个名字,即使它是完整版.
我知道:我有1个InfoPlist.strings文件,它与本地化相乘,我可以将它们分配给目标.因此对于1 App我可以本地化BundleDisplayName.
但是,如何为第二个应用分配特定名称?
我在视图控制器按钮操作中有以下代码:
- (IBAction)requestPermissions:(id)sender
{
DDLogInfo(@"Start permission requesting.");
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)]){
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
}
}
Run Code Online (Sandbox Code Playgroud)
注册完成后,didBecomeActive会发布通知,我正在检查用户做了什么:
-(void)didBecomeActive:(NSNotification *)notification
{
if([[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone){
// if user decline
}
} else {
// if user accept
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:如果用户拒绝接收推送通知并稍后决定启用它们(设置 - >通知中心 - >我的应用程序),则会出现一个惊喜:设置中启用了"警报","徽章"和"声音" ,但应用程序返回 UIRemoteNotificationTypeNone.
有什么想法有什么不对?
注:我知道这些方法现在已经过时,所以请不要告诉我用registerForRemoteNotifications:和UIUserNotificationSettings,它已经完成.
我正在尝试获取基于 SPM 的依赖目标,我Package.swift在这里定义了:
所以我RxSwift在包依赖项中定义了它,但它没有在目标中使用ReCaptcha,而仅在目标中使用ReCaptchaRx
如果我选择仅选择一个目标而不是Rx我期望的,它只会获取ReCaptcha依赖项并忽略Rx.
仅导入后,ReCaptcha我得到的包已解析但无法使用,如果我在导入窗口中选择,ReCaptchaRx我将得到预期的可用 Rx,这很好。但为什么RxSwift在这种情况下 SPM 还要获取并解析呢?
为什么 Xcode 解析RxSwift不依赖于它的目标?这可以预防吗?我期望与AppSwizzle此示例中类似的行为,即如果不使用目标则不会得到解决。
这是一个开源库: https://github.com/JakubMazur/ReCaptcha/blob/swift-package-manager/Package.swift
如果您想在 SPM 中检出此内容,将从https://github.com/JakubMazur/ReCaptcha分支上解析包swift-package-manager
我想改变plist文件为了不编程,但在Xcode.在Xcode中有哪种方法可以按值排序?我只是想为自己安排.现在,如果我想要添加新项目,它将永远是尾巴.

怎么排序呢?到100的价值去顶部?
我有一些全局对象(几乎在所有应用程序屏幕中使用),并且大多数是在应用程序启动后立即创建的.我想从我的所有ViewControllers访问这些对象(没有别的,只有ViewControllers).在哪里存放?
我想@property,AppDelegate但我认为(但我可能是错的)这是一个丑陋的解决方案.
对象可能非常复杂,这不是一个简单的类型.
我已经在互联网上倾倒了几天,试图弄清楚如何实现这一点.
我需要从twitter请求访问令牌和秘密,以便将其传递给将为我的应用程序处理用户推文的服务器.
我一直关注此链接https://dev.twitter.com/docs/ios/using-reverse-auth
问题是第1步.他们没有给你一个步骤1的例子.
这是我的代码:
NSURL *url = [NSURL URLWithString:TW_OAUTH_URL_REQUEST_TOKEN];
NSDictionary *parameters = @{TW_X_AUTH_MODE_KEY:TW_X_AUTH_MODE_REVERSE_AUTH};
SLRequest *getTwitterAuth = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:parameters];
// Assume that we stored the result of Step 1 into a var 'resultOfStep1'
NSString *S = resultOfStep1;
NSDictionary *step2Params = [[NSMutableDictionary alloc] init];
[step2Params setValue:@"kfLxMJsk7fqIuy8URhleFg" forKey:@"x_reverse_auth_target"];
[step2Params setValue:S forKey:@"x_reverse_auth_parameters"];
NSURL *url2 = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];
SLRequest *stepTwoRequest =
[SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:url2 parameters:step2Params];
// You *MUST* keep the ACAccountStore alive for as long as you need an …Run Code Online (Sandbox Code Playgroud) 我正在尝试CoreData在我的Cocoa Touch Framework中使用.我创建一个简单的项目作为示例:https:
//github.com/JakubMazur/SO41698466
基本上我是按步骤做的:
CoreData到项目someDataModelCoreData一些虚拟实体并将模块更改为Current Product ModuleSomeClass开始,它基本上被称为:.
public class func entityCreation() {
Entity(context: CoreDataClass().persistentContainer.viewContext)
}
Run Code Online (Sandbox Code Playgroud)
因此,使用lazy来自CoreData的这个自动生成的代码,这应该创建模型.
.
func testExample() {
SomeClass.entityCreation()
}
Run Code Online (Sandbox Code Playgroud)
CoreDataClass我把断点以下行:
let container = NSPersistentContainer(name: "someDataModel")然后我在控制台中看到:[error]错误:无法加载名为someDataModel CoreData的模型:错误:无法加载名为someDataModel的模型
所以我有两个问题:
NSPersistentContainer名字吗?有一种方法可以检查我应该放在那里?在这里下载项目:https://github.com/JakubMazur/SO41698466
找到并添加解决方案如下
let modelURL = Bundle(for: type(of: self)).url(forResource: "someDataModel", withExtension: "momd")!
let managedObjectModel = NSManagedObjectModel(contentsOf: modelURL)
let …Run Code Online (Sandbox Code Playgroud) ios ×8
objective-c ×4
xcode ×4
swift ×3
plist ×2
cocoa-touch ×1
core-audio ×1
core-data ×1
localization ×1
slrequest ×1
twitter ×1