У меня есть UIDatePicker в TableView со статическими ячейками. DatePicker отлично работает в iPhone версии приложения, но iPad, похоже, сжимает DatePicker, так что центральный столбец, в котором хранится день месяца (dd), не отображается. Обратите внимание, что "er" в "Ноябре" усечен.
Я проверил это, изменив стиль даты на испанский (dd MMMM YYY), и отобразится дата, как и первая половина месяца и весь год. Последняя половина каждого месяца называется усеченной.
Кто-нибудь столкнулся с такой проблемой при переносе на iOS 8?
Не уверен, сколько кода для публикации. Здесь больше всего в соответствующем классе
@property (strong, nonatomic) IBOutlet UITableViewCell *dateDisplay;
@property (strong, nonatomic) IBOutlet UITableViewCell *datePickerCell;
@property (strong, nonatomic) IBOutlet UIDatePicker *datePicker;
@property (strong, nonatomic) IBOutlet UITableViewCell *unattached;
@property (strong, nonatomic) IBOutlet UITableViewCell *middleschool;
@property (strong, nonatomic) IBOutlet UITableViewCell *highschool;
@property (strong, nonatomic) IBOutlet UITableViewCell *collegiate;
@property (strong, nonatomic) IBOutlet UITableViewCell *youthclub;
@end
@implementation MeetFinderTableViewController
@synthesize divisions = _divisions;
@synthesize datePickerIndexPath = _datePickerIndexPath;
@synthesize meetDate = _meetDate;
@synthesize doSaveUserDefaults = _doSaveUserDefaults;
@synthesize divisionSelected = _divisionSelected;
@synthesize arrayOfReuseIds = _arrayOfReuseIds;
@synthesize myTV = _myTV;
# pragma SplitViewController Variables
@synthesize meetIDForSegue = _meetIDForSegue;
@synthesize meetNameForSegue = _meetNameForSegue;
#pragma SetUp Configuration
-(void) setArrayOfReuseIds:(NSArray *)arrayOfReuseIds
{
_arrayOfReuseIds = arrayOfReuseIds;
}
-(void) setMyTV:(UITableView *)myTV
{
_myTV = myTV;
}
-(void) setMeetDate:(NSDate *)meetDate
{
if(_meetDate != meetDate){
_meetDate = meetDate;
[self setDoSaveUserDefaults:YES];
}
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (MapViewController *)splitViewMapViewController
{
id mvc = [self.splitViewController.viewControllers lastObject];
if (![mvc isKindOfClass:[MapViewController class]]) {
mvc = nil;
}
if (debug==1) NSLog(@"%@ = %@",NSStringFromSelector(_cmd), mvc);
return mvc;
}
- (void)awakeFromNib
{
[super awakeFromNib];
self.splitViewController.delegate = self;
if (debug==1) NSLog(@"Do I make it to %@",NSStringFromSelector(_cmd));
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = YES;
self.datePicker.hidden = YES;
self.datePickerIsShowing = NO;
[self setArrayOfReuseIds:[[NSArray alloc] initWithObjects:
@"unattached",@"middleschool",@"highschool",@"collegiate",@"youthclub", nil]];
[self setDivisions:[[NSArray alloc] initWithObjects:
@"Unattached", @"Middle School", @"High School",
@"Collegiate", @"Youth Club", nil]];
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"divisionPreference"]) {
[self setDivisionSelected:[[NSUserDefaults standardUserDefaults] objectForKey:@"divisionPreference"]];
} else [self setDivisionSelected:[NSNumber numberWithInt:highSchoolTag]];
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"datePreferenceForMeetSearch"]) {
[self setMeetDate:[[NSUserDefaults standardUserDefaults] objectForKey:@"datePreferenceForMeetSearch"]];
} else [self setMeetDate:[NSDate date]];
[self setMyTV:self.tableView];
if (debug==1) NSLog(@"In %@ before check splitViewMapViewController",NSStringFromSelector(_cmd));
if ([self splitViewMapViewController]) { // if in split view
[self splitViewMapViewController].dateForSearch = self.meetDate;
[self splitViewMapViewController].levelOfCompetition = [self.divisionSelected stringValue];
}
}
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setupDateLabel];
[self setUpMenuItems];
if (debug==1) NSLog(@"Do I make it to %@",NSStringFromSelector(_cmd));
}
-(void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:YES];
if (self.doSaveUserDefaults) {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:self.divisionSelected
forKey:@"divisionPreference"];
[userDefaults setObject:self.meetDate
forKey:@"datePreferenceForMeetSearch"];
[userDefaults synchronize];
NSLog(@"Getting ready to set newPreferences with divisionSelected: %@ and dateOfMeet: %@", [self.divisionSelected stringValue], self.meetDate);
MapPreferencesDataDelegate *newPreferences = [[MapPreferencesDataDelegate alloc]
initWithName:[self.divisionSelected stringValue]
dateOfMeet:self.meetDate];
[self.delegate saveMeetSearchPreferences:newPreferences];
}
}
- (void)setupDateLabel {
self.dateFormatter = [[NSDateFormatter alloc] init];
[self.dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[self.dateFormatter setTimeStyle:NSDateFormatterNoStyle];
NSDate *defaultDate;
if (!self.meetDate || self.meetDate == nil) {
defaultDate = [NSDate date];
[self setMeetDate:defaultDate];
} else defaultDate = self.meetDate;
self.dateDisplay.textLabel.text = [NSString stringWithFormat:@"%@",stringForDateDisplay];
self.dateDisplay.textLabel.textColor = [self.tableView tintColor];
self.dateDisplay.detailTextLabel.text = [self.dateFormatter stringFromDate:defaultDate];
self.dateDisplay.detailTextLabel.textColor = [self.tableView tintColor];
}
- (void)showDatePickerCell {
self.datePickerIsShowing = YES;
[self.tableView beginUpdates];
[self.tableView endUpdates];
self.datePicker.hidden = NO;
self.datePicker.alpha = 0.0f;
[UIView animateWithDuration:0.25 animations:^{
self.datePicker.alpha = 1.0f;
}];
}
- (void)hideDatePickerCell {
self.datePickerIsShowing = NO;
[self.tableView beginUpdates];
[self.tableView endUpdates];
[UIView animateWithDuration:0.25
animations:^{
self.datePicker.alpha = 0.0f;
}
completion:^(BOOL finished){
self.datePicker.hidden = YES;
}];
}
-(void) placeCheckMarkForDivisionSelection:(NSInteger) myDivisionPreference
#pragma mark - Table view data source
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
case 0:
{
if (indexPath.row == 0){
self.datePicker.hidden = NO;
self.datePickerIsShowing = !self.datePickerIsShowing;
[UIView animateWithDuration:.4 animations:^{
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:1 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadData];
}];
}
break;
}
case 1:
{
UITableViewCell *cell1 = [tableView cellForRowAtIndexPath:indexPath];
NSInteger tagForSelectedDivision = cell1.tag;
[self placeCheckMarkForDivisionSelection:tagForSelectedDivision];
//
[self setDivisionSelected:[NSNumber numberWithInteger:tagForSelectedDivision]];
if ([self splitViewMapViewController]) [self splitViewMapViewController].levelOfCompetition = [self.divisionSelected stringValue];
break;
}
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 && indexPath.row == 1) { // this is my picker cell
if (self.datePickerIsShowing) {
return 219;
} else {
return 0;
}
} else {
return self.tableView.rowHeight;
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return numberOfSections;
}
#pragma mark - Action methods
- (IBAction)pickerDateChanged:(UIDatePicker *)sender {
if ([self splitViewMapViewController]) { // if in split view
[self splitViewMapViewController].dateForSearch = sender.date;
[self splitViewMapViewController].levelOfCompetition = [self.divisionSelected stringValue];
}
self.dateDisplay.detailTextLabel.text = [self.dateFormatter stringFromDate:sender.date];
self.meetDate = sender.date;
[self setMeetDate:sender.date];
}
- (void) displayAlertBoxWithTitle:(NSString*)title message:(NSString*) myMessage cancelButton:(NSString*) cancelText
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:myMessage
delegate:nil
cancelButtonTitle:cancelText
otherButtonTitles:nil];
[alert show];
}
#pragma SplitViewController Implementation
- (id <SplitViewBarButtonItemPresenter>)splitViewBarButtonItemPresenter
{
id detailVC = [self.splitViewController.viewControllers lastObject];
if (![detailVC conformsToProtocol:@protocol(SplitViewBarButtonItemPresenter)]) {
detailVC = nil;
}
return detailVC;
}
- (BOOL)splitViewController:(UISplitViewController *)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation
{
return NO;
}
- (void)splitViewController:(UISplitViewController *)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)pc
{
barButtonItem.title = barButtonItemTitle;
[self splitViewBarButtonItemPresenter].splitViewBarButtonItem = barButtonItem;
}
- (void)splitViewController:(UISplitViewController *)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
[self splitViewBarButtonItemPresenter].splitViewBarButtonItem = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end
Спасибо,