如何在集合視圖頂部添加自定義視圖? 我想用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];
}
,但它並沒有幫助
確定在第一它不是我的問題,但現在這是我的問題,但無論 我有編輯問題@丹尼爾·萊納德 –
你現在的問題是什麼? –