我在这里阅读了很多帖子,整天都通过Apple文档阅读.这里的帖子都没有答案,文档在这个问题上也不清楚.
我们有一个应用程序在使用Dev配置文件时接收推送通知,但在我们使用企业分发配置文件时却没有.
应用程序ID已启用沙箱中的推送通知.
证书和两个配置文件都与应用程序ID相关联.
如果我构建表单Xcode推送通知就可以了.如果我存档并分发服务器返回:
[Failed to push 6dje7djksis7hyhdjshsjksjd74jdjskshdjd8dhjjdkwu for reason 8]
Run Code Online (Sandbox Code Playgroud)
这是无效令牌.
我注意到的一件事是我们的开发配置文件具有以下用于aps环境:
<key>aps-environment</key>
<string>development</string>
Run Code Online (Sandbox Code Playgroud)
企业分发配置文件具有:
<key>aps-environment</key>
<string>production</string>
Run Code Online (Sandbox Code Playgroud)
当我运行调试版本到我的手机(推送工作)时.app文件的权利是:
<key>aps-environment</key>
<string>development</string>
Run Code Online (Sandbox Code Playgroud)
当我归档时,它们总是(无论我使用什么配置文件或方案):
<key>aps-environment</key>
<string>production</string>
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我这是否是预期的?我能够找到的这个网站上的其他问题实际上都没有提出Dev为什么会工作但是Enterprise Distribution不会的原因.
为什么归档始终会生成aps环境?
谢谢你的时间.
更新 这很有趣.
从:
"您必须为沙箱(开发)环境和生产环境获取单独的证书.证书与作为推送通知的接收者的应用程序的标识符相关联;此标识符包括应用程序的包ID.当您创建配置文件时对于其中一个环境,必需的权利会自动添加到配置文件中,包括特定于推送通知的权利.这两个配置文件称为开发和分发.分发配置文件是将应用程序提交到App Store的要求".
这可能意味着除非您要进行生产,否则不要使用分发配置文件.真的吗?这似乎很奇怪,因为您可以在进入应用商店之前制作企业分发配置文件.
有人对此有所了解吗?我在文档中找不到任何具体信息.
谢谢
我已经阅读了Apple文档,并且我已经控制了这些论坛,我已经(成功)完成了一些教程并成为了我自己的代表,但我仍然不明白.我确信这是我的间隔,但由于我已经做了尽职调查,但仍然不知道我做错了什么,我希望你们中的一个能够告诉我.
情况:
我有一个自定义的UITableViewCell,里面有一个按钮.当点击按钮时,我试图将UIImagePickerController表单拉出这个自定义单元格的委托.我可以捕获并响应按钮点击没问题,但流程永远不会转到委托方法.换句话说,当我逐步执行代码时,一切都很好,直到我尝试从按钮目标方法步进到第二个类中的委托方法.它永远不会被调用.
这是代码.
在自定义单元格的接口文件中,我为委托设置了id,为UIButton设置了IBOutlet,并设置了协议方法:
#import <UIKit/UIKit.h>
@protocol CustomPicCellDelegate;
@interface CustomPicCell : UITableViewCell <UITextInputTraits> {
UIButton *picButton;
...
id<CustomPicCellDelegate> cellDelegate;
}
@property (nonatomic, retain) IBOutlet UIButton *picButton;
...
@property (nonatomic, assign) id<CustomPicCellDelegate> cellDelegate;
...
- (IBAction)getAPic;
@end
@protocol CustomPicCellDelegate <NSObject>
- (void)getPhoto;
@end
Run Code Online (Sandbox Code Playgroud)
UIButton连接到IB中的getAPic方法.
在自定义单元格的实现文件中,我将UIButton目标的方法放在里面,并尝试在委托中调用委托方法:
#import "CustomPicCell.h"
@implementation CustomPicCell
@synthesize cellDelegate;
...
- (IBAction)getAPic {
NSLog(@"You are here ...");
if (cellDelegate && [cellDelegate respondsToSelector:@selector(getPhoto)]) {
[cellDelegate getPhoto];
}
}
Run Code Online (Sandbox Code Playgroud)
在委托类接口中,我将其设置为自定义单元格的委托:
@interface DelegateClass : UIViewController < ... CustomPicCellDelegate> { …
Run Code Online (Sandbox Code Playgroud) 我正在尝试减少这两个条形按钮项之间的距离.
我正在使用
navigationItem setRightBarButtonItems
Run Code Online (Sandbox Code Playgroud)
设置两个按钮项目,但它们相距太远.
我试过添加负空间,我尝试在它之后添加一个垫片,固定空间,灵活空间.在文档中没有看到任何说明你无法改变间距但我找不到的方法.
我在这里先向您的帮助表示感谢.
编辑后编辑:
Siu Chung Chan的回答是完全正确的,但由于我一开始并没有得到它,我想我会分享让我意识到他完全正确的代码.
如果你把它全部放在一个区块中,这就是他(非常正确)的答案:
UIView *filterBtnView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
UIButton *filterBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
[filterBtn addTarget:self action:@selector(someMethod) forControlEvents:UIControlEventTouchUpInside];
[filterBtn setBackgroundImage:[UIImage imageNamed:@“someicon”] forState:UIControlStateNormal];
[filterBtnView addSubview:filterBtn];
UIBarButtonItem *btnFilter = [[UIBarButtonItem alloc] initWithCustomView:filterBtnView];
UIView *selectBtnView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
UIButton *selectBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
[selectBtn setBackgroundImage:[UIImage imageNamed:@“someothericon”] forState:UIControlStateNormal];
[selectBtn addTarget:self action:@selector(someOtherMethod:) forControlEvents:UIControlEventTouchUpInside];
[selectBtnView addSubview:selectBtn];
UIBarButtonItem *btnSelect = [[UIBarButtonItem …
Run Code Online (Sandbox Code Playgroud) 我有一个 Obj C 项目,我已经向其中添加了一个 Swift viewController。
我正在尝试将故事板附加到 viewController。
我可以以编程方式向视图添加内容,但无法显示故事板。
我还尝试使用 xib 作为 Swift viewController 的竞争,但没有运气。
从 didSelectRowAtInexPath 调用 Swift vie form Obj C:
SwiftController *sc = [[SwiftController alloc] init];
[self.navigationController pushViewController:sc animated:YES];
Run Code Online (Sandbox Code Playgroud)
SwiftController.swift:
import Foundation
import UIKit
@objc class SwiftController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// This prints
println("in the scrolling view")
// This works
self.view.backgroundColor = .redColor();
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
故事板正确连接:
这就是我每次得到的:
使用 …
编辑:在解决这个问题几天之后我真正的问题如下:1.UITableView是否占用了整个视图?
2.如果是这样,它如何设置单元格的边界,看起来它只占用视图的一部分.3.如何获得细胞的边界 - 或者更准确地说,我如何知道细胞占据的可见区域的边界.self.tableView.bounds.size.width无效,因为它返回视图的宽度.谢谢.留下以前的信息,以防它有助于使我的问题更清晰.
这有可能吗?我已经阅读了苹果文档,并在这里和其他地方拖累了论坛,无法找到并回答这个问题.无论你做什么,UITableVIew中的页脚是否实际占据了整个视图?它没有表宽度的概念吗?
例:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
[footerView setBackgroundColor:[UIColor redColor]];
return footerView;
}
Run Code Online (Sandbox Code Playgroud)
此代码将从一个边缘到另一个边缘创建一条红线.无论你给它什么边界,线都将占据整个视图.这样做的问题是,如果您想要在该页脚中居中标签,那么如果您支持方向更改,则无法知道中心位置.例如,在iPad应用程序中,我尝试执行以下操作:
if ([footerText length] > 0) {
UIView *customView = [[[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 0, 0.0)] autorelease];
[customView setBackgroundColor:[UIColor grayColor]];
UILabel *footerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
footerLabel.numberOfLines = 2;
footerLabel.adjustsFontSizeToFitWidth = NO;
[footerLabel setTextAlignment:UITextAlignmentCenter];
[footerLabel setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5]];
[footerLabel setOpaque:NO];
[footerLabel setTextColor:[UIColor whiteColor]];
[footerLabel setShadowColor:[UIColor lightGrayColor]];
[footerLabel setFont:[UIFont boldSystemFontOfSize:14]];
[footerLabel setFrame:CGRectMake(customView.center.x/0.3, 0.0, …
Run Code Online (Sandbox Code Playgroud) 似乎有很多类似于我遇到的问题:
AVCaptureMetadataOutput setMetadataObjectTypes找不到支持的类型
还有一个处理AVFoundation的Apple bug:
https://forums.developer.apple.com/thread/86810#259270
但这些似乎都不是我的答案.
我的代码在swift 3中运行得很好,但只会在swift 4中出错.使用上面链接中的解决方案根本不会发生任何变化.
码:
import UIKit
import AVFoundation
class BarCodeScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
weak var delegate: FlowControllerDelegate?
var captureSession: AVCaptureSession = AVCaptureSession()
var previewLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.black
captureSession = AVCaptureSession()
guard let videoCaptureDevice = AVCaptureDevice.default(for: .video) else { return }
let videoInput: AVCaptureDeviceInput
do {
videoInput = try AVCaptureDeviceInput(device: videoCaptureDevice)
} catch {
return
}
if (captureSession.canAddInput(videoInput)) {
captureSession.canAddInput(videoInput)
} else { …
Run Code Online (Sandbox Code Playgroud) 我有一个通过HTTP从Apache服务器获取的字符串:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
...
Run Code Online (Sandbox Code Playgroud)
我需要将该字符串设为UTF16字符串.我不想把它变成NSData.我需要保持NSString,我需要它在UTF16.我很乐意将它放在一个NSData对象中,如果我可以将其作为UTF16.我现在正在做类似的事情:
[self.returnedData appendData:data];
Run Code Online (Sandbox Code Playgroud)
但是仍然将它转换为UTF8.它可能很简单,我很想念它.但是我没有在Apple文档或这个网站上找到它,而我的Google-Fu也让我失望了.我错过了什么?我怎么做?谢谢你的时间和帮助.
编辑:好的.你和贾斯汀所说的一切都是有道理的,让事情变得更有意义.所以这就是我在做的事情.这条线似乎是正确的,但我想确保我正确理解你.
NSData *resultData = [self. result dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
NSString *resultStr = [[NSString alloc] initWithData:resultData encoding:NSUTF16LittleEndianStringEncoding];
NSString *md5Result = [[NSString stringWithFormat:@"%@",[resultStr MD5]] uppercaseString];
NSLog(@"md5Result = %@",md5Result);
Run Code Online (Sandbox Code Playgroud)
最后一部分就是我在UTF-16之后用字符串做的事情.我有一个类别,使其成为类似于http://blog.blackwhale.at/?tag=hmac的MD5十六进制字符串 再次感谢.我会碰到你们两个,并说这是正确的答案.
ios ×5
objective-c ×2
uitableview ×2
avfoundation ×1
delegates ×1
footer ×1
nsstring ×1
orientation ×1
storyboard ×1
swift ×1
swift4 ×1
tableview ×1
uibutton ×1
utf-16 ×1
xcode9 ×1