短視訊程式碼,摺疊cell的使用
短視訊程式碼,摺疊cell的使用實現的相關程式碼
完整程式碼如下:
@property (nonatomic, strong) UITableView* foldTableView;
@property (nonatomic, strong) NSMutableArray* foldArray;
@property (nonatomic, strong) UIButton* foldButton;
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
_foldTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 100, 380, 50) style:UITableViewStylePlain];
_foldTableView.delegate = self;
_foldTableView.dataSource = self;
[self.view addSubview:_foldTableView];
[_foldTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"normal"];
_foldArray = [NSMutableArray arrayWithObjects:@"內容1", @"內容2", @"內容3", @"內容4", @"內容5", @"內容6", @"內容7", nil];
_foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_foldButton.layer setMasksToBounds:YES];
[_foldButton.layer setCornerRadius:15.0];
[_foldButton setTitle:@"點選展開" forState:UIControlStateNormal];
[_foldButton setTitle:@"點選收起" forState:UIControlStateSelected];
[_foldButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_foldButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
_foldButton.backgroundColor = [UIColor yellowColor];
_foldButton.titleLabel.font = [UIFont systemFontOfSize:20];
[_foldButton addTarget:self action:@selector(pressFoldButton:) forControlEvents:UIControlEventTouchUpInside];
_foldButton.frame = CGRectMake(0, 0, 380, 50);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _foldArray.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* normalCell = [_foldTableView dequeueReusableCellWithIdentifier:@"normal" forIndexPath:indexPath];
[normalCell.layer setMasksToBounds:YES];
[normalCell.layer setCornerRadius:15.0];
if (indexPath.row == 0) {
[normalCell.contentView addSubview:_foldButton];
} else {
normalCell.textLabel.text = _foldArray[indexPath.row - 1];
normalCell.textLabel.textColor = [UIColor blackColor];
normalCell.textLabel.textAlignment = NSTextAlignmentCenter;
normalCell.textLabel.font = [UIFont systemFontOfSize:20];
normalCell.backgroundColor = [UIColor yellowColor];
}
return normalCell;
}
- (void)pressFoldButton:(UIButton*)button {
if (button.selected == YES) {
button.selected = NO;
_foldTableView.frame = CGRectMake(10, 100, 380, 50);
} else if (button.selected == NO) {
button.selected = YES;
_foldTableView.frame = CGRectMake(10, 100, 380, 50 * _foldArray.count);
}
}
以上就是 短視訊程式碼,摺疊cell的使用實現的相關程式碼,更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2844625/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Sublime程式碼摺疊
- intelliJ idea程式碼摺疊IntelliJIdea
- vscode摺疊展開程式碼VSCode
- 騰訊又出短視訊小程式“看一看短視訊”。短視訊原始碼有巨大潛力?原始碼
- VS中使用預處理指令#pragma region自由摺疊程式碼
- 短視訊平臺原始碼,彈性佈局實現自適應高度cell原始碼
- 短視訊直播系統開發直播短視訊程式搭建短視訊互動直播
- 直播短視訊原始碼短視訊APP短視訊帶貨系統多商戶直播原始碼APP
- 使用Jquery和CSS摺疊影象jQueryCSS
- 短視訊直播原始碼,EditText輸入框的使用原始碼
- 【Eclipse】--Eclipse摺疊程式碼外掛foldingEclipse
- 短視訊程式碼,ViewPager滑動方向改變Viewpager
- 短視訊的哪些創新功能為短視訊原始碼提供良好的借鑑?原始碼
- VsCode顯示左邊摺疊程式碼+-按鈕VSCode
- 短視訊原始碼,python使用post提交圖片原始碼Python
- 短視訊seo優化,短視訊seo排名優化
- 京東小程式摺疊屏適配探索
- 微信小程式過長文字摺疊效果的探索微信小程式
- 短視訊原始碼,視訊轉為圖片儲存原始碼
- BootStrap | 例項 - 摺疊boot
- java之常量摺疊Java
- 【BootStrap】--摺疊外掛boot
- UI之可摺疊的TextViewUITextView
- 給 RecyclerView 加上摺疊的效果View
- 短視訊系統原始碼,各個視訊正常排序排列原始碼排序
- 友盟+短視訊行業研究: 5.9億使用者的狂歡,短視訊的“舞臺社交”行業
- js橫向滑動摺疊導航選單程式碼例項JS
- js和css實現的扇子展開和摺疊效果程式碼例項JSCSS
- 短視訊商城在ios短視訊開發上的應用效果iOS
- win7系統摺疊組視窗設定不折疊操作步驟Win7
- 短視訊程式原始碼,PageSlider實現滑動頁面原始碼IDE
- 短視訊直播原始碼,自定義圖片或視訊的迴圈播放原始碼
- 短視訊帶貨原始碼,觀看視訊時雙擊放大原始碼
- 短視訊“音訊化”,音樂“視訊化”音訊
- 短視訊技術詳解:Android端的短視訊開發技術Android
- 可摺疊iPhone概念設計圖:手機可摺疊秒變筆記本iPhone筆記
- 曝蘋果摺疊屏iPhone再度延期2年!或將研發可摺疊MacBook蘋果iPhoneMac
- 直播平臺原始碼,可摺疊式選單欄原始碼