【发布时间】:2018-02-09 12:18:56
【问题描述】:
我很多天都面临这个问题。请大家解决这个问题。
下面是我的 rows 数组,numberOfRowsInSection 应该传入哪个计数?
(
(
"Service Speed",
"Good Service",
"Confirmation quality",
"Quick Service in Reservation"
),
(
"Check In",
"Happy on their Service",
Courtesey,
"Quick Service at Checkin"
),
(
"Front office & reception",
"Overall Quality of Room",
Check,
"Response time"
),
(
"Room Decor",
"Time taken to serveTime taken to serveTime taken t",
Bathroom,
"Facilities in the Room",
"Choice of menu",
Housekeeping,
"Room Service"
),
(
"Overall Comments",
"Will you come back again"
),
"Guest Satisfaction Ratings"
)
我的问题是,如何传递numberOfRowsInSection 中的行数组计数和cellForRowAtIndexPath 中的数组值?
我尝试使用以下代码,但出现错误:
"[__NSCFString count]: 无法识别的选择器发送到实例"
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [GroupName count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [GroupName objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[RowsArr objectAtIndex:section] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.Label.text = [[sections objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
}
问题出在数组的最后一个对象中 “客人满意度评分”, 因为它来自 NSString,所以只有它显示错误。
【问题讨论】:
-
将
"Guest Satisfaction Ratings"放入具有单个对象的数组中。它是由 api 服务器端而不是你纠正的。 -
好的,当然。感谢您的建议。
标签: ios objective-c arrays iphone uitableview