uitableview

How to make UITableView Header selectable?

試著忘記壹切 提交于 2020-01-20 03:51:10
问题 I have made a custom section-header for UITableView, that includes some controls like segmented control, UIImageView ,etc. It successfully appears, but it's not tappable so I can't interact with its controls. I need to know how can I make this header view selectable? 回答1: There is no way to do it with the UITableViewDelegate. You have to add a UITapGestureRecognizer to yourHeaderView Like: UITapGestureRecognizer *singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action

iOS开发拓展篇—音频处理(音乐播放器3)

怎甘沉沦 提交于 2020-01-20 03:02:43
iOS开发拓展篇—音频处理(音乐播放器3) 说明: 这篇文章主要介绍音频工具类和播放工具类的封装。 一、控制器间数据传递 1.两个控制器之间数据的传递 第一种方法:self.parentViewController.music=self.music[indexPath.row];不能满足 第二种做法:把整个数组传递给它 第三种做法:设置一个数据源,设置播放控制器的数据源是这个控制器。self.parentViewController.dataSource=self;好处:没有耦合性,任何实现了协议的可以作为数据源。 第四种做法:把整个项目会使用到的音频资源交给一个工具类去管理,这样就不用传递过去了。直接向工具类索要资源就可以。 二、封装一个音频工具类 新建一个音频工具类,用来管理音乐数据(音乐模型)    工具类中的代码设计如下: YYMusicTool.h文件 1 // 2 // YYMusicTool.h 3 // 4 5 #import <Foundation/Foundation.h> 6 @class YYMusicModel; 7 @interface YYMusicTool : NSObject 8 /** 9 * 返回所有的歌曲 10 */ 11 + (NSArray *)musics; 12 13 /** 14 * 返回正在播放的歌曲 15 */ 16 +

Change cell height by the content of the textView inside the cell

非 Y 不嫁゛ 提交于 2020-01-19 13:58:28
问题 I have a Table View called todoTableView with cells that created by the user. Each cell has Text View. I want to change the height of the cell by the content of the Text View. This is what I tried: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: TableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath:indexPath) as! TableViewCell cell.bounds.size.height = cell.textView.bounds.size.height return cell }

UITableView - Directly setting tableHeaderView property vs. Implementing -viewForHeaderInSection method

余生颓废 提交于 2020-01-19 12:49:25
问题 What's the difference between directly setting the tableHeaderView/tableFooterView properties: UIView *headerView = [[UIView alloc] init...]; tableView.tableHeaderView = headerView; [headerView release]; and implementing the viewForHeaderInSection/viewForFooterInSection methods?: - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[[HeaderView alloc] init...] autorelease]; return headerView; } 回答1: the first is the header of a table

UITableView - Directly setting tableHeaderView property vs. Implementing -viewForHeaderInSection method

陌路散爱 提交于 2020-01-19 12:48:30
问题 What's the difference between directly setting the tableHeaderView/tableFooterView properties: UIView *headerView = [[UIView alloc] init...]; tableView.tableHeaderView = headerView; [headerView release]; and implementing the viewForHeaderInSection/viewForFooterInSection methods?: - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[[HeaderView alloc] init...] autorelease]; return headerView; } 回答1: the first is the header of a table

How to pass data to detail view after being selected in a table view?

守給你的承諾、 提交于 2020-01-19 11:52:47
问题 I have a UITableViewController that has data populated from an NSMutableArray called userList. When specific user is selected, it goes to a detail view, and updates the title in the NavBar, but it wont pass the data to update a UILabel in the UIView. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:NO]; //Attempt at a singleton to pass the data DetailView *details = [[DetailView alloc] init];

UITableView insert rows without scrolling

本小妞迷上赌 提交于 2020-01-19 04:59:06
问题 I have a list of data that I'm pulling from a web service. I refresh the data and I want to insert the data in the table view above the current data, but I want to keep my current scroll position in the tableview. Right now I accomplish this by inserting a section above my current section, but it actually inserts, scrolls up, and then I have to manually scroll down. I tried disabling scrolling on the table before this, but that didn't work either. This looks choppy and seems hacky. What is a

How can I create a big, red UIButton with iOS?

Deadly 提交于 2020-01-18 11:08:48
问题 Using iOS, how would I go about creating a red "delete" button similar to the one used when deleting contacts on the iPhone? 回答1: You first start with a stretchable image: alt text http://grab.by/4lP Then you make a button with the stretched image as the background and apply text. UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeCustom]; [sampleButton setFrame:CGRectMake(kLeftMargin, 10, self.view.bounds.size.width - kLeftMargin - kRightMargin, 52)]; [sampleButton setTitle:@

Custom edit view in UITableViewCell while swipe left. Objective-C or Swift

六眼飞鱼酱① 提交于 2020-01-18 04:46:25
问题 How to make a custom edit view in iOS7 UITableView with Objective C like the Evernote or the Apple Reminders app while swipe left. I have tried to set an custom editingAccessoryView, but this didn't work. Evernote edit view: Reminders edit view: My current code is - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:

Why one bname value showing its paramName count times in tableview while parsing in swift?

戏子无情 提交于 2020-01-17 17:48:04
问题 my JSON: { "id": "70", "bname": "Municipal Corporation - Water", "bcategoryname": "Water", "bcustomerparms": "[{\"paramName\":\"Consumer Number\",\"dataType\":\"NUMERIC\",\"optional\":\"false\",\"minLength\":\"1\",\"maxLength\":\"10\"}, {\"paramName\":\"Mobile Number\",\"dataType\":\"NUMERIC\",\"optional\":\"false\",\"minLength\":\"10\",\"maxLength\":\"10\"}, {\"paramName\":\"Email . Id\",\"dataType\":\"ALPHANUMERIC\",\"optional\":\"false\",\"minLength\":\"5\",\"maxLength\":\"100\"}]", } "id"