小编hyb*_*ttt的帖子

无法更改UIInputView高度

我有一个简单的UIInputViewController子类,只有两个重写的方法.我inputAccessoryViewController在我的UIViewController子类上使用此输入视图控制器,它成为第一响应者.我尝试通过添加约束来指定inputView的高度,如Apple文档所建议的那样.问题是我的约束不起作用,并且在添加约束时我得到autolayout异常

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
...
(
    "<NSLayoutConstraint:0x178aa1d0 V:[UIInputView:0x178a4ae0(0)]>",
    "<NSLayoutConstraint:0x178b9520 V:[UIInputView:0x178a4ae0(500)]>"
)
Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x178b9520 V:[UIInputView:0x178a4ae0(500)]>
Run Code Online (Sandbox Code Playgroud)

我认为这意味着系统已经为输入视图添加了零高度约束(因为它创建的高度为零).现在他们冲突和自动布局打破我的约束来解决问题.

当我尝试使用它作为inputViewController我的视图控制器(仅用于测试目的)时,我得到相同的异常,但不是零高度,它是216 px.它也打破了我的约束,高度保持默认.

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    self.inputView.translatesAutoresizingMaskIntoConstraints = NO;
    self.inputView.backgroundColor = [UIColor redColor];
}

- (void)updateViewConstraints {

    CGFloat _expandedHeight = 500;
    NSLayoutConstraint *_heightConstraint = …
Run Code Online (Sandbox Code Playgroud)

objective-c ios autolayout ios8 uiinputviewcontroller

10
推荐指数
1
解决办法
2541
查看次数

没有取消分配带有inputAccessoryView的UIViewController

我有UIViewController的简单子类(下面的代码).如果我附加inputAccessoryView,我的viewcontroller永远不会被释放.如果我没有在viewDidLoad中设置inputAccessoryView,则按预期调用dealloc.

我错过了什么吗?

@interface IMTestViewController : UIViewController

@property (nonatomic, strong) UIView *messageInputView;
@property(nonatomic, readwrite, strong) UIView *inputAccessoryView;

@end

@implementation IMTestViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.inputAccessoryView = self.messageInputView;
}

- (BOOL)canBecomeFirstResponder
{
    return YES;
}

- (UIView *)messageInputView
{
    if (_messageInputView == nil)
    {
        _messageInputView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 45)];
        _messageInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    } …
Run Code Online (Sandbox Code Playgroud)

objective-c uiviewcontroller uiresponder ios ios7

8
推荐指数
1
解决办法
2891
查看次数

在iOS 7上分组UITableView故障

我在Xcode4.6中构建我的应用程序并使用iOS7在iPod5上运行它.

表视图已分组,所有单元格都是标准的.表处于一个部分的编辑模式.在处于编辑模式的单元格上有一个非常奇怪的故障.问题显示在屏幕截图上(有毛刺和正常).

这个"东西"只出现了片刻,我只能在viewDidAppear的dispatch_async中捕获它.然后片刻之后它会自动消失并且一切正常(cellForRowAtIndexPath,单元格中的layoutSubviews没有被调用,我没有重新加载表格! - 最奇怪的事情).

我的表和单元格非常复杂,但我挖掘并删除了所有不相关的视图.这里的表是透明的,红色是它后面的视图的颜色.我已将cell.contentView.alpha设置为零(我的所有视图都添加到其中),并且单元格本身为绿色.我试过cell.alpha = 0,在这种情况下,单元格没有显示并且没有毛刺,所以它肯定是一个单元格的问题.

请写下任何建议,我没有想法.谢谢.

UPD.看起来这只发生在编辑模式下.如果我没有把它设置为YES,一切都没问题.UPD 2. [table setEditing:YES]调用时出现毛刺.如果是动画,则表明此事物扩展到单元格的正常宽度并变为正常.我开始认为它无法解决(显然Apple不会解决它)

毛刺 正常

objective-c uitableview ios ios7

6
推荐指数
1
解决办法
689
查看次数

CoreData:获取与NSDictionaryResultType的多对多关系的计数

我在Core Data中有一个很大的对象列表(大约50 000并且会定期增加).我用以下请求获取它:

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[SongObject name]];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
fetchRequest.propertiesToFetch = @[@"uid", @"name", @"toArtistRef.uid", @"toArtistRef.name"];
fetchRequest.resultType = NSDictionaryResultType;
Run Code Online (Sandbox Code Playgroud)

实体SongObject也包含关系toSongsInPlaylistRef,它是to-many.

我需要为每个对象获取此set的计数.由于数据量很大,我无法获取关系本身.我尝试添加 @"toSongsInPlaylistRef.@count",@"toSongsInPlaylistRef.count" 但它崩溃了

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Invalid to many relationship in setPropertiesToFetch: (toSongsInPlaylistRef.count)'
Run Code Online (Sandbox Code Playgroud)

请写下任何建议.

core-data objective-c ios

3
推荐指数
1
解决办法
1446
查看次数