I am building an app which should run on iOS7 and on iOS6. For the iOS6 version I'm trying to achieve a similar look and feel than the iOS7 version.
Now I want to get the headerView of a section on iOS6 look similar to the one on iOS7.
With the approach below its looks ok on iOS6.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
if (sectionTitle == nil) {
return nil;
}
// Create label with section title
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont startProduktView_landLabelFont];
label.frame = CGRectMake(5, 6, 300, 30);
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor darkGrayColor];
label.shadowColor = [UIColor clearColor];
label.shadowOffset = CGSizeMake(0.0, 0.0);
label.text = sectionTitle;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 21)];
[view addSubview:label];
return view;
}
However, the issue I am facing now is that this is also applied to the iOS7 version. But in the iOS 7 version the header should appear as standard. So basically it would be great if there would be some way that this delegate method won't be called at all under iOS7. Is this possible?
You can't make a particular version of iOS not call a standard delegate method that you have implemented. You could check the OS version and then supply an OS6 or OS7 specific class as the delegate, with different implementations for the methods. Alternately you can just have your code run and not worry that you are explicitly creating the section header labels.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다