Xcode 6的这个新功能有点烦人.大多数时候我不需要设置相对于边距的偏移量,如果我这样做,我可能想要使用默认值16以外的值.有没有办法更改默认值或完全禁用我的项目的边距(或所有我的Xcode中的项目)?
我EXC_BAD_ACCESS在Foundation的-[NSData(NSData) getBytes:length:]方法中遇到了一个奇怪的崩溃.它经常发生,但我无法从堆栈跟踪中获得任何有意义的信息.getBytes:length:除了开源库(一进SDWebImage一出SocketRocket)之外,我的代码内部没有调用,但它们似乎并没有导致崩溃.
唯一的提示是崩溃发生在com.apple.CFNetwork.addPersistCacheToStorageDaemon线程内部,但我不知道它是什么.有人可以帮忙吗?
来自Crashlytics的Stacktrace:
Thread : Crashed: com.apple.CFNetwork.addPersistCacheToStorageDaemon
0 libsystem_platform.dylib 0x3044a208 _platform_memmove$VARIANT$CortexA9 + 160
1 Foundation 0x22df9167 -[NSData(NSData) getBytes:length:] + 118
2 Foundation 0x22df9167 -[NSData(NSData) getBytes:length:] + 118
3 Foundation 0x22e21a1b -[NSData(NSData) replacementObjectForCoder:] + 134
4 Foundation 0x22dc2aff -[NSXPCEncoder _replaceObject:] + 90
5 Foundation 0x22e240dd -[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 192
6 Foundation 0x22e212ff -[NSDictionary(NSDictionary) encodeWithCoder:] + 922
7 Foundation 0x22dc32c9 -[NSXPCEncoder _encodeObject:] + 604
8 Foundation 0x22dc379d encodeInvocationArguments + …Run Code Online (Sandbox Code Playgroud) 所以我正在尝试发送带有大图像文件的multipart/form-data POST请求.我不能预先将文件转换为字节数组,我的应用程序会因OutOfMemory异常而崩溃,所以我必须将文件的内容直接写入连接的输出流.此外,我的服务器不支持分块模式,因此我必须在发送数据之前计算内容长度并使用连接的setFixedLengthStreamingMode.
public void createImagePostWithToken(String accessToken, String text,
String type, String imagePath) {
URL imageUrl = null;
String lineEnd = "\r\n";
String twoHyphens = "--";
// generating byte[] boundary here
HttpURLConnection conn = null;
DataOutputStream outputStream = null;
DataInputStream inputStream = null;
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int maxBufferSize = 1*1024*1024;
try
{
long contentLength;
int serverResponseCode;
String serverResponseMessage;
File file = new File(imagePath);
FileInputStream fileInputStream = new FileInputStream(file);
imageUrl = buildUri("posts").toURL();
conn = (HttpURLConnection)imageUrl.openConnection();
conn.setConnectTimeout(30000);
conn.setReadTimeout(30000);
conn.setDoOutput(true);
conn.setDoInput(true); …Run Code Online (Sandbox Code Playgroud) 我正在使用vfr-reader库编写PDF阅读器.要在横向中显示两个页面,我将每个页面呈现为自己的视图,然后将这两个视图添加到容器视图,然后将容器视图添加到滚动视图.每个视图的autoresizingMask设置为UIViewAutoresizingNone,contentMode设置为UIViewContentModeRedraw,autoresizingSubviews设置为所有视图的"NO".
但仍然以某种方式容器视图自动调整以适应滚动视图的高度,我不知道这发生在哪里.我关心这个,因为,当自动化容器视图时,它的宽度变得比屏幕宽度大,并且我无法通过单次滑动滚动到接下来的两个页面(需要两次滑动),这很糟糕.我错过了什么?
编辑会增加一些来,如果它有帮助.在ViewController中,我创建了一个Scroll View,其中包含以下选项:
theScrollView = [[ReaderScrollView alloc] initWithFrame:viewRect];
theScrollView.scrollsToTop = NO;
theScrollView.pagingEnabled = YES;
theScrollView.delaysContentTouches = NO;
theScrollView.showsVerticalScrollIndicator = NO;
theScrollView.showsHorizontalScrollIndicator = NO;
theScrollView.contentMode = UIViewContentModeRedraw;
theScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
theScrollView.backgroundColor = [UIColor clearColor];
theScrollView.userInteractionEnabled = YES;
theScrollView.autoresizesSubviews = NO;
theScrollView.delegate = self;
[self.view addSubview:theScrollView];
Run Code Online (Sandbox Code Playgroud)
当我正在绘制页面时,我正在向Scroll View添加一个UIView,这是以这种方式启动的:
if ((self = [super initWithFrame:frame]))
{
self.autoresizesSubviews = YES;
self.userInteractionEnabled = YES;
self.contentMode = UIViewContentModeRedraw;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.backgroundColor = [UIColor clearColor];
theScrollView = [[ReaderScrollView alloc] initWithFrame:self.bounds]; // …Run Code Online (Sandbox Code Playgroud) 这里已经提出了类似的问题,但没有回答.我正在开发iOS应用程序,用于已经在其网站上拥有自己的帐户系统的服务.使用您的帐户,您可以订阅优质服务以获得高质量视频等其他功能.
我正在尝试在iOS应用程序中实现相同的功能.如果用户购买了替代品,则必须将其连接到系统中的帐户,而不是他的Apple ID.如果他退出并使用其他帐户授权,则他无法使用订阅权益,并且必须为第二个帐户购买另一个订阅.
我可以使用应用内购买实现此功能吗?
ios ×4
objective-c ×2
xcode ×2
android ×1
autolayout ×1
crash ×1
nsdata ×1
post ×1
storekit ×1
uiview ×1