调用reloadItemsAtIndexPaths后,UICollectionView动画项目(淡入淡出动画).
有没有办法避免这个动画?
iOS 6
有A类:
@interface ClassA : NSObject {
}
@property (nonatomic, assign) id prop1;
@end
@implementation
@synthesize prop1;
@end
Run Code Online (Sandbox Code Playgroud)
然后我有子类
@interface ClassB : ClassA {
}
@end
@implementation
- (id)init {
self = [super init];
if (self) {
}
return self;
}
//This is infinite loop
- (void) setProp1:(id)aProp
{
self.prop1 = aProp;
}
@end
Run Code Online (Sandbox Code Playgroud)
这是无限循环,因为ClassB中的setProp1从ClassB中调用[ClassB setProp1:val].
我已经尝试过调用[super setProp1]但是这个
如何覆盖@property并在覆盖的setter中分配值?我们假设我无法修改ClassA.
UIViewController
用UIView
和UITableView
UIView
|-UITableView
Run Code Online (Sandbox Code Playgroud)
我正在尝试设置这样的边距:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.layoutMargins = UIEdgeInsetsMake(30, 30, 30, 30);
self.tableView.preservesSuperviewLayoutMargins = YES;
[self.view layoutIfNeeded];
}
Run Code Online (Sandbox Code Playgroud)
但是这个观点没有发生任何事情.
以下是InterfaceBuilder的约束
(lldb) po self.view.constraints
<__NSArrayM 0x786ab6e0>(
<NSLayoutConstraint:0x7896e940 UIView:0x7896e470.trailingMargin == UITableView:0x79b51a00.trailing - 16>,
<NSLayoutConstraint:0x7896e970 UITableView:0x79b51a00.leading == UIView:0x7896e470.leadingMargin - 16>,
<NSLayoutConstraint:0x7896e9a0 V:[_UILayoutGuide:0x7896e510]-(0)-[UITableView:0x79b51a00]>,
<NSLayoutConstraint:0x7896e9d0 V:[UITableView:0x79b51a00]-(0)-[_UILayoutGuide:0x7896e600]>,
<_UILayoutSupportConstraint:0x7896c7d0 V:[_UILayoutGuide:0x7896e510(0)]>,
<_UILayoutSupportConstraint:0x7896c2b0 V:|-(0)-[_UILayoutGuide:0x7896e510] (Names: '|':UIView:0x7896e470 )>,
<_UILayoutSupportConstraint:0x7896cbf0 V:[_UILayoutGuide:0x7896e600(0)]>,
<_UILayoutSupportConstraint:0x7896ea00 _UILayoutGuide:0x7896e600.bottom == UIView:0x7896e470.bottom>
)
Run Code Online (Sandbox Code Playgroud)
结果没有看到任何边缘,没有任何改变....我正在发布什么?
iOS 8
这可能是一个简单的问题,但为什么在我的课堂上实施NSCopying协议,我得到zone == nil
- (id)copyWithZone:(NSZone *)zone
{
if (zone == nil)
NSLog(@"why this is allways nil");
(...)
}
Run Code Online (Sandbox Code Playgroud)
对于带有对象的复制数组,使用此方法调用此方法.
[[NSArray alloc] initWithArray:myArray copyItems:YES]];
Run Code Online (Sandbox Code Playgroud) 如何插入UINavigationController
内部UITabBarController
.
目前我UITabBarController
在应用程序委托中主要使用declatarion(所以tab是main)
self.window.rootViewController = self.tabBarController;
Run Code Online (Sandbox Code Playgroud)
在我希望插入的一个标签内UINavigationController
,并且无法获取它.
代码构造如下:
MainWindow.xib
使用UITabBarController
选项卡键入的对象UINavigationController
(指向NavigationHistory.xib
) - 屏幕截图:无效链接NavigationHistory.xib
仅包含UINavigationController
View.xib的视图History.xib
只有UITableView
元素 - 截图:无效链接现在UIViewController
不显示我的View1视图,我不知道它为什么会这样.也许你有任何线索?或者指向我进行此类配置的地方.
我有代表
@property (nonatomic, assign) id <DelegateProtocol> delegate;
Run Code Online (Sandbox Code Playgroud)
但它在performSelector上崩溃了
if (_delegate != nil && [_delegate conformsToProtocol:@protocol(DelegateProtocol)])
{
NSObject *obj = _delegate;
//HERE IS EXC_BAD_ACCESS
[obj performSelectorOnMainThread:@selector(didTouchImageView:) withObject:self waitUntilDone:NO];
}
Run Code Online (Sandbox Code Playgroud)
我在这里设置代表:
- (void)viewDidLoad
{
[super viewDidLoad];
[invoiceTabImage setDelegate:self];
}
Run Code Online (Sandbox Code Playgroud)
问题是为什么会这样.
使用@synthesize生成的setter是否应该对KVC进行编译?我发现声明生成的getter和setter符合KVC,不应该调用其中一种方法吗?
@interface testing : NSObject
@property (nonatomic, retain) NSString *phone;
@end
Run Code Online (Sandbox Code Playgroud)
执行:
@implementation testing
@synthesize phone;
- (id)init {
self = [super init];
return self;
}
// none of these is called with dot syntax, or setter setPhone
- (void)setValue:(id)value forKey:(NSString *)key
{
NSLog(@"%@",key);
[super setValue:value forKey:key];
}
-(void)setValue:(id)value forKeyPath:(NSString *)keyPath
{
NSLog(@"%@",keyPath);
[super setValue:value forKeyPath:keyPath];
}
@end
Run Code Online (Sandbox Code Playgroud)
并测试它:
testing *t = [[testing alloc] init];
[t setPhone:@"55555555"];
Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×5
animation ×1
autolayout ×1
delegates ×1
ios6 ×1
ios8 ×1
kvc ×1
layout ×1
nsarray ×1
nscopying ×1
overriding ×1
subclass ×1
uitableview ×1
uiview ×1