如何在集合视图顶部添加自定义视图? 我想用Xcode的用户界面 我已经加入我的观点在故事板视图控制器,但集合视图覆盖它 所以我在viewDidLoad中如何将自定义视图添加到JSQMessagesViewController中
- (void)viewDidLoad {
[super viewDidLoad];
[self addViewOnTop];
}
}
-(void)addViewOnTop {
UIView *selectableView = [[UIView alloc]initWithFrame:CGRectMake(0, 60, self.view.bounds.size.width, 40)];
selectableView.backgroundColor = [UIColor redColor];
UILabel *randomViewLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 100, 16)];
randomViewLabel.text = @"RandomView";
[selectableView addSubview:randomViewLabel];
[self.view addSubview:selectableView];
}
此代码成功,但如何运行添加自定义视图设计自定义视图使用Xcode的界面生成器可以装入一个视图或加载的.xib文件
现在我做这个
@implementation chatViewController
- (void)viewDidLoad {
[super viewDidLoad];
[SVProgressHUD dismiss];
self.collectionView.collectionViewLayout.sectionInset = UIEdgeInsetsMake(70, 0, 0, 0);
self.collectionView.dataSource = self;
self.collectionView.delegate= self;
messages = [NSMutableArray array];
[self addMessages];
self.collectionView.collectionViewLayout.incomingAvatarViewSize = CGSizeZero;
self.collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero;
self.topContentAdditionalInset = 70.0f;
UITapGestureRecognizer* tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleCollectionTapRecognizer:)];
[self.collectionView addGestureRecognizer:tapRecognizer];
self.collectionView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
[self addViewOnTop];
}
-(void)addViewOnTop {
commentsheader *test = [[commentsheader alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 70)];
[self.view addSubview:test];
}
,但它并没有帮助
确定在第一它不是我的问题,但现在这是我的问题,但无论 我有编辑问题@丹尼尔·莱纳德 –
你现在的问题是什么? –