根据文件 UIVIew @property(nonatomic) CGFloat alpha
此属性的值是0.0到1.0范围内的浮点数,其中0.0表示完全透明,1.0表示完全不透明. 此值仅影响当前视图,不会影响其任何嵌入的子视图.
我有一个容器视图配置如下:
self.myView.backgroundColor = [UIColor blackColor];
self.myView.alpha = 0.5;
[self addSubview:self.myView];
Run Code Online (Sandbox Code Playgroud)
然后将子视图添加到'myView'
[myView addSubView anotherView];
anotherView.alpha = 1;
NSLog(@"anotherView alpha = %f",anotherView.alpha); // prints 1.0000 as expected
Run Code Online (Sandbox Code Playgroud)
但' anotherView '在屏幕上确实有alpha(它不像预期的那样不透明)
这怎么可能,可以做些什么?
我正在尝试导入各种库,我不记得他们的确切名称.不幸的是Xcode 6(使用swift)并没有像使用objective-c 在Xcode 5中那样自动完成它们.
例如:
ALAssetsLibrary
MPMediaPlayer
Run Code Online (Sandbox Code Playgroud)
等等
我被迫谷歌确切的框架名称,然后返回并复制粘贴.
通常,自动完成工作非常糟糕.我在Xcode 6中做错了吗?
我应该在设置中设置任何标志以使其工作吗?
我已经通过设置视图的图层属性看到了一些lagyness问题的修复
view.layer.shouldRasterize = YES;
Run Code Online (Sandbox Code Playgroud)
我在使用UICollectionView并准备单元格和设置属性时看到了很大的性能差异.
不确定其含义是什么.
得到解释会很棒.谢谢!
我在我的应用程序中使用了一个库UICollectionView.细胞大小约为70,70.我使用ALAssets从ALAssetLibrary我在其中已经存储在列表中的画廊.
我使用通常的模式来填充单元格:
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
mycell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
mycell.imageView.image = [[UIImage imageWithCGImage:[alassetList objectAtIndex:indexpath.row] thumbnail]];
return mycell;
}
Run Code Online (Sandbox Code Playgroud)
我的画廊滚动波涛汹涌.我不明白为什么会这样.我已经尝试添加一个NSCache来缓存缩略图(想想可能创建图像很昂贵),但这对性能没有帮助.
我希望用户界面像股票应用程序一样黄油.
我现在怀疑它可能是某种东西UICollectionViewCell prepareForReuse可能会阻碍dequeueReusableCellWithReuseIdentifier方法,但使用我无法找到的工具.
还有其他可能造成这种情况的事吗?是否有一种"更快"的方式以更快的方式UICollectionViewCell为dequeue它们做准备?
objective-c ios xcode-instruments uicollectionview uicollectionviewcell
我在异步(串行)工作队列中有一个长时间运行的函数.我知道有时这个函数会在特定的openCV调用中挂起.由于某种原因,这个挂起也导致主线程挂起.暂停并进入调试模式时,我看到有一个调用
semaphore_wait_trap()
Run Code Online (Sandbox Code Playgroud)
在主线程(队列)上
我可以在调试模式下挂起挂起的线程(我的工作队列)然后这个陷阱消失,GUI再次在手机上响应.
在取消暂停工作线程后,GUI响应1-2秒(我怀疑再次激活此线程)然后UI再次无响应.
该线程不dispatch_sync()调用主线程/队列
IOS是否可能暂停主线程("陷阱")因为工作者长时间运行?
我可以强制它去掉块吗?
我正在添加调试模式堆栈的一些打印屏幕.
暂停挂起队列之前:

和挂线:

暂停和暂停坏队列后:

我需要知道何时重新加载UICollectionView已经完成以便以后配置单元格(因为我不是单元格的数据源 - 其他明智的就是已经完成它...)
我试过像这样的代码
[self.collectionView reloadData];
[self configure cells]; // BOOM! cells are nil
Run Code Online (Sandbox Code Playgroud)
我也试过用
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadData];
} completion:^(BOOL finished) {
// notify that completed and do the configuration now
}];
Run Code Online (Sandbox Code Playgroud)
但是当我重新加载数据时,我正在崩溃.
如何将数据重新加载到集合中,并且只有在完成重新加载后才能重新加载 - 执行特定的完成处理程序
objective-c-blocks completionhandler uicollectionview uicollectionviewcell
我仍然不确定struct copy或reference的规则.
我想在从数组迭代它时改变一个struct对象:例如在这种情况下我想改变背景颜色但是编译器对我大喊大叫
struct Options {
var backgroundColor = UIColor.blackColor()
}
var arrayOfMyStruct = [MyStruct]
...
for obj in arrayOfMyStruct {
obj.backgroundColor = UIColor.redColor() // ! get an error
}
Run Code Online (Sandbox Code Playgroud) 我见过的解决方案是重置模拟器.但没有帮助.
得到这些错误.
2013-10-20 13:27:11.097 a[2204:a0b] Cannot find executable for CFBundle 0xddc93b0 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/GeoServices.axbundle> (not loaded)
2013-10-20 13:27:11.143 a[2204:a0b] Cannot find executable for CFBundle 0xddf2b60 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle> (not loaded)
2013-10-20 13:27:11.148 a[2204:a0b] Cannot find executable for CFBundle 0xdd6a2e0 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/MusicLibrary.axbundle> (not loaded)
2013-10-20 13:27:11.151 a[2204:a0b] Cannot find executable for CFBundle 0xdd67b20 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/StoreKitFramework.axbundle> (not loaded)
2013-10-20 13:27:11.166 a[2204:a0b] Cannot find executable for CFBundle 0xd9cf6e0 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/SocialFramework.axbundle> (not loaded)
2013-10-20 13:27:11.170 a[2204:a0b] Cannot find executable for CFBundle 0xd9d5f20 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/TwitterFramework.axbundle> (not loaded)
Run Code Online (Sandbox Code Playgroud) 是否可以通过扩展将协议合规性添加到不同的协议?
例如,我们希望A符合B:
protocol A {
var a : UIView {get}
}
protocol B {
var b : UIView {get}
}
Run Code Online (Sandbox Code Playgroud)
我想给B类的对象提供B的默认实现(合规性)
// This isn't possible
extension A : B {
var b : UIView {
return self.a
}
}
Run Code Online (Sandbox Code Playgroud)
动机是在需要B的情况下重用A的对象而不创建我自己的"桥"
class MyClass {
func myFunc(object : A) {
...
...
let view = object.a
... do something with view ...
myFunc(object) // would like to use an 'A' without creating a 'B'
}
func myFunc2(object : B) {
...
... …Run Code Online (Sandbox Code Playgroud) 对行为不确定,因为我怀疑我遇到了僵局,
我有一个包含多个对象的类 - 每个对象创建一个具有相同名称的队列.我不确定GCD是否在对象之间重用相同的队列,或者它们是否只是共享相同的名称.
例如
@interface MyClass
-(void)doSomeWork
@property (nonatomic,strong) dispatch_queue_t myQueue;
@end
@implementation MyClass
-(id)init
{
self = [super init];
self.myQueue = dispatch_queue_create("MyQueue",DISPATCH_QUEUE_SERIAL);
return self;
}
-(void)doSomeWork
{
dispatch_async(self.myQueue,^{
// some long running work
});
}
@end
@interface SomeClassWhichCreatesALotOfObjects
@end
@implementation SomeClassWhichCreatesALotOfObjects
-(void)someMethod
{
for(int i = 0; i < 10000; i++)
{
MyClass *object = [MyClass new];
[object doSomeWork]; // are these running in serial to each other or are each offset to the queue their object has …Run Code Online (Sandbox Code Playgroud) ios ×7
objective-c ×4
swift ×3
uiview ×2
xcode ×2
autocomplete ×1
copy ×1
hang ×1
mutable ×1
protocols ×1
rasterizing ×1
semaphore ×1
struct ×1