我实现了一个UITableView带有更多功能的负载.tableView从有时很慢的服务器加载大图像.我正在为每个图像启动一个URLConnection并重新加载对应于URLConnection的indexPath(与连接对象一起保存).连接本身调用-reloadDatatableView.
现在,当单击加载更多按钮时,我滚动到位置底部的新数据集的第一行.这很好用,也是我的异步加载系统.
我面临以下问题:当连接"太快"时,tableView正在重新加载给定indexPath的数据,而tableView仍然滚动到新数据集的第一个单元格,tableView向后滚动一半的高度细胞.
这应该是它应该是什么样子以及它实际上做了什么:

^^^^^^^^^^^^ should ^^^^^^^^^^^^ ^^^^^^^^^^^^^ does ^^^^^^^^^^^^^
以下是一些代码:
[[self tableView] beginUpdates];
for (NSMutableDictionary *post in object) {
[_dataSource addObject:post];
[[self tableView] insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:[_dataSource indexOfObject:post] inSection:0]] withRowAnimation:UITableViewRowAnimationBottom];
}
[[self tableView] endUpdates];
[[self tableView] scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[_dataSource indexOfObject:[object firstObject]] inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
Run Code Online (Sandbox Code Playgroud)
-tableView:cellForRowAtIndexPath:如果数据源数组中的对象是字符串,则启动JWURLConnection,并将其替换UIImage为完成块中的实例.然后它重新加载给定的单元格:
id image = [post objectForKey:@"thumbnail_image"];
if ([image isKindOfClass:[NSString class]]) {
JWURLConnection *connection = [JWURLConnection connectionWithGETRequestToURL:[NSURL URLWithString:image] delegate:nil startImmediately:NO];
[connection setFinished:^(NSData *data, NSStringEncoding encoding) {
[post setObject:[UIImage imageWithData:data] forKey:@"thumbnail_image"]; …Run Code Online (Sandbox Code Playgroud) 我想将其放在项目网页的“进度”部分中。我尝试使用iframe,并且尝试使用$.load(),但是这些都不起作用。
有任何想法吗?
我在使用jQuery和原生JavaScript(NOT prototype.js)时遇到了问题.使用以下代码时,jQuery 1.9.1带有错误消息:
Object.prototype.myVeryGreatFunction = function() {
// ...
}
[Error] TypeError: undefined is not a function (evaluating 'U[a].exec(s)')
ft (jquery.min.js, line 4)
wt (jquery.min.js, line 4)
st (jquery.min.js, line 4)
find (jquery.min.js, line 4)
init (jquery.min.js, line 3)
b (jquery.min.js, line 3)
(anonymous function) (read.control.js, line 59)
c (jquery.min.js, line 3)
fireWith (jquery.min.js, line 3)
ready (jquery.min.js, line 3)
H (jquery.min.js, line 3)
Run Code Online (Sandbox Code Playgroud)
当我删除原型定义时,一切都很好.不幸的是,我无法轻松更新jQuery,因为这是一个CMS的插件,因此出于兼容性原因,它必须使用旧版本.
是否有任何已知问题或修复此问题?
谷歌搜索实际上向我展示了使用jQuery.noConflict()和私人功能包装等解决方案.但如上所述,我不是使用prototype.js,而是使用本机 JS对象原型.
在我的应用程序中,我有自定义tableViewCells与固定比率(16x9).为了实现这一点,我在单元格中放置了一个视图,将其固定到其父视图(尽管我在界面构建器中进行了操作:) V/H:|-[innerView]-|.另外,我对它进行了比率约束.
在我的tableViewController中,我UITableViewAutomaticDimension用作表格单元格高度.
估计的行高是180,这是单元在320px宽显示器上的确切尺寸(正如你所看到的那样).
我仍在部署8.4,但是在使用iOS 9的设备上运行项目时,我收到了大量的自动布局警告,尽管一切正常并且看起来很完美.
警告本身是绝对正确的.有两个我不想要的限制 - 这些是iOS自己添加的.
2015-09-29 11:24:57.771 app[1039:324736] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for …Run Code Online (Sandbox Code Playgroud) 我有点困惑.我在Xcode5的界面构建器中找到了"选定的图像色调颜色".我试图使用它,因为我真的喜欢在IB中进行颜色调整这样简单的事情,而不是为它编写代码:

此功能绝对没有效果.当我更改颜色时,它不适用于已编译的应用程序.我已经尝试清理,清除,删除DerivedData目录并启动一个新项目.
任何人都可以告诉我为什么这不起作用?
我使用下面的代码来访问我的iOS应用程序中的联系人.它在iOS <10中运行良好,但是Xcode 8和iOS 10崩溃了:
- (void)btcContacts_tap {
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted) {
_addressBookController = [[ABPeoplePickerNavigationController alloc] init];
[[_addressBookController navigationBar] setBarStyle:UIBarStyleBlack];
_addressBookController.delegate = self;
[_addressBookController setPredicateForEnablingPerson:[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty]];
[_addressBookController setPeoplePickerDelegate:self];
[self presentViewController:_addressBookController animated:YES completion:nil];
}
else {
dispatch_async(dispatch_get_main_queue(), ^{
[self showMessage:NSLocalizedStringFromTable(@"PLEASE_GRANT_CONTACTS", LIApplicationLanguage(), nil) andAdvertise:@"" andService:nil andTransactionState:kTTTransactionStateInfo];
});
}
});
}
Run Code Online (Sandbox Code Playgroud)
我已经设置NSSetUncaughtExceptionHandler了一个记录崩溃报告的方法,但即使是异常处理程序也没有调用...
其他人也遇到过这个问题吗?
我目前正在努力使用Mac OS X中的动态UI.我创建了一个菜单栏项,并希望在其中添加动态计数的MenuItems.
元素的数量取决于计算机上的网络接口.我的Mac有两个接口,另一个可能只有一个或三个.
元素的创建不是问题.但是我想在后面的代码中引用这些元素.
-(void)addItems
{
NSMenuItem *menuItem = [menu addItemWithTitle:@"Start" action:@selector(click:) keyEquivalent:@""];
}
Run Code Online (Sandbox Code Playgroud)
然后我想更新元素的标题:
-(IBAction)click:(id)sender
{
[menuItem setTitle:@"Clicked!"];
}
Run Code Online (Sandbox Code Playgroud)
原因是,"click"动作返回未声明的标识符(menuItem).问题是,我不能在头文件中声明它们,因为它们是动态的,它们可能达到100个项目的数量,因此我不能声明10个项目并使用它们.
我该如何处理这些情况?希望你能帮我!
招呼,朱利安
我正在编写一个小 WP 主题,需要有关新的 CSS3 背景大小属性的一些帮助。
\n\n我有一个 DIV,其中包含图像作为背景。图像本身设置得比 div 更大,以呈现原始图像的一点剪切:
\n\n.imageContainer {\n background-size:154% 102%;\n background-position-x:-28%;\n background-position-y:0.28%;\n}\nRun Code Online (Sandbox Code Playgroud)\n\n到目前为止一切都很好。但是,如果大小为 \xe2\x89\xa5 100%,则调用背景位置属性会变得很棘手。\n我组合了一个小 JS/CSS Playground 进行测试:
\n\n对于以下情况,我计算了:
\n\n因此,我渲染了一个页面(包括自动计算),并且大小大约是正确的大小。\n但正如我所说,较少的背景位置 x (-28%) 意味着图像正确,图像位置错误。
\n\n它必须向左移动,因为我计算出-28%“左边距”。所以我做了一些尝试和错误,结果发现正确的位置应该是 …
我制作了一个应用程序,要求用户授予可访问性功能的权限。它在应用程序首次启动并要求可访问性时正常工作
const void * keys[] = { kAXTrustedCheckOptionPrompt };
const void * values[] = { force };
CFDictionaryRef options = CFDictionaryCreate(kCFAllocatorDefault,
keys,
values,
sizeof(keys) / sizeof(*keys),
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
access = AXIsProcessTrustedWithOptions(options);
CFRelease(options);
Run Code Online (Sandbox Code Playgroud)
问题是,当我发布新版本(使用 sparkle)时,可访问性权限消失了,所以用户应该再次授予权限。那是因为我的代码没有使用 Apple Developer ID 签名吗?我正在应用商店之外分发我的应用。
我对蓝牙通信很陌生.我的第一个项目打算将数据从iOS设备传输到BLEshield(小芯片).
为了测试我的中央代码,我决定设置一个iPhone作为外围设备(芯片将拥有的角色,一旦我拿到它)和一个iPad作为中心.
我可以连接设备,也可以将数据从外设发送到中心.这很容易:
- (void)startService {
_readChar = [[CBMutableCharacteristic alloc] initWithType:[CBUUID ...] properties:CBCharacteristicPropertyNotify value:nil permissions:CBAttributePermissionsReadable];
_writeChar = [[CBMutableCharacteristics alloc] initWithType:[CBUUID ...] properties:CBCharacteristicPropertyNotify value:nil permissions:CBAttributePermissionsWriteable];
_service = [[CBMutableService alloc] initWithType:[CBUUID ...] primary:YES];
[_service setCharacteristics:@[_readChar, _writeChar]];
_peripheral = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];
[_peripheral addService:_service];
[_peripheral startAdvertising:@{CBAdvertisementDataServiceUUIDKey: @[[CBUUID ...]], CBAdvertisementDataLocalNameKey: @"ServiceName"}];
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic {
[_peripheral updateValue:[@"HELLO WORLD" dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:_readChar onSubscribedCentrals:nil];
}
Run Code Online (Sandbox Code Playgroud)
但我不能让另一个方向发挥作用.要从中央发送数据,我有以下代码:
[_activePeripheral writeValue:[@"PONG" dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:_writeChar type:CBCharacteristicWriteWithoutResponse];
Run Code Online (Sandbox Code Playgroud)
我假设应该在外设上调用这些方法中的任何一个:
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray …Run Code Online (Sandbox Code Playgroud) ios core-bluetooth bluetooth-lowenergy cbperipheral cbcentralmanager
objective-c ×4
ios ×3
uitableview ×2
add ×1
cbperipheral ×1
conflict ×1
css ×1
dynamic ×1
github ×1
html ×1
ios10 ×1
ios9 ×1
javascript ×1
jquery ×1
macos ×1
nsmenu ×1
nsmenuitem ×1
prototype ×1
reloaddata ×1
sparkle ×1
tintcolor ×1
uitabbar ×1
xcode5 ×1