【发布时间】:2014-08-31 17:10:26
【问题描述】:
我正在开发应用程序,在该应用程序中我使用 [self performSegueWithIdentifier:@"newViewSegue" sender:self]; 从另一个人那里呈现新的 UIViewController
在新的UIViewController 中,我正在初始化我的视图元素并以编程方式将UITableView 添加到其中。
但是当我调用这个performSegueWithIdentifier new UIViewController 在延迟一段时间后显示时,我尝试在viewDidLoad 的新UIViewController 和[self performSegueWithIdentifier:@"newViewSegue" sender:self]; 语句之前输入日志,这两个语句都会立即执行,但会显示视图一段时间后。
我的ViewDidLoad方法如下:
-(void)viewDidLoad{
sharedObject=[SingleToneClass sharedManager];
selectedButtonTag=-1;
initFlag=0;
NSLog(@"End %@",[NSDate date]);
backgroundView.backgroundColor=[self hexToUiColor:@"E7E7E7"];
[mondayDateButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//set colour for all 7days buttons
[mondayDateButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14]];
//Set font for all days button
[mondayButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//set title colour
[mondayButton.titleLabel setFont:[UIFont systemFontOfSize:12]];
//set font
//Changing image Color
//Home Button
[homeButton.titleLabel setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:40]];
[homeButton setTitleColor:[self hexToUiColor:sharedObject.secondaryHexColorCode] forState:UIControlStateNormal];
[homeButton setTitle:[NSString fontAwesomeIconStringForIconIdentifier:@"fa-home"] forState:UIControlStateNormal];
//Back Button
[backButton.titleLabel setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:27]];
[backButton setTitleColor:[self hexToUiColor:sharedObject.secondaryHexColorCode] forState:UIControlStateNormal];
[backButton setTitle:[NSString fontAwesomeIconStringForIconIdentifier:@"fa-chevron-left"] forState:UIControlStateNormal];
//Next Week Button
[nextWeek.titleLabel setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:20]];
[nextWeek setTitleColor:[self hexToUiColor:sharedObject.secondaryHexColorCode] forState:UIControlStateNormal];
[nextWeek setTitle:[NSString fontAwesomeIconStringForIconIdentifier:@"fa-chevron-right"] forState:UIControlStateNormal];
//Previous Week Button
[previousWeek.titleLabel setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:20]];
[previousWeek setTitleColor:[self hexToUiColor:sharedObject.secondaryHexColorCode] forState:UIControlStateNormal];
[previousWeek setTitle:[NSString fontAwesomeIconStringForIconIdentifier:@"fa-chevron-left"] forState:UIControlStateNormal];
[separatorLineView setBackgroundColor:[self hexToUiColor:@"6D6D6D"]];
[selectLabel setTextColor:[self hexToUiColor:@"6D6D6D"]];
[selectLabel setFont:[UIFont boldSystemFontOfSize:13]];
selectLabel.text=[NSString stringWithFormat:@"%@",selectedTitle];
sharedObject.bookADateTitle=selectedTitle;
//make Buttons Rounded
mondayDateButton.clipsToBounds = YES;
mondayDateButton.layer.cornerRadius = mondayDateButton.frame.size.height/2;
NSDate *currentDate;
if (sharedObject.bookDateViewDate.length>0) {
NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init];
[dateFormat1 setDateFormat:@"yyyy-MM-dd"];
currentDate=[dateFormat1 dateFromString:sharedObject.bookDateViewDate];
}
else{
currentDate=[NSDate date];
}
[self setDate:currentDate];
[self setDateToLabel:currentDate]; //set formatted date
//create and initialise UITableView
static NSString *cellIdentifier=@"CustomHiddenViewCell";
CustomHiddenViewCell *cell = (CustomHiddenViewCell *)[slotsTableView dequeueReusableCellWithIdentifier:cellIdentifier];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomHiddenViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
double heightOfTable=(self.view.frame.size.height-backgroundView.frame.size.height);
//creating tableview1
slotsTableView=[[UITableView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y+backgroundView.frame.size.height,self.view.frame.size.width,heightOfTable)];
slotsTableView.scrollEnabled=YES;
slotsTableView.delegate=self;
[slotsTableView flashScrollIndicators];
slotsTableView.dataSource=self;
slotsTableView.bounces=NO;
slotsTableView.showsVerticalScrollIndicator=YES;
slotsTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
[self.view addSubview:slotsTableView];
//add swipe gesture
UISwipeGestureRecognizer *leftSwipRecognizer;
leftSwipRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(SwipeRecognizer:)];
[leftSwipRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[slotsTableView addGestureRecognizer:leftSwipRecognizer];
UISwipeGestureRecognizer *rightSwipRecognizer;
rightSwipRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(SwipeRecognizer:)];
[rightSwipRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[slotsTableView addGestureRecognizer:rightSwipRecognizer];
[leftWeekRecognizer addTarget:self action:@selector(WeekSwipeRecognizer:)];
[leftWeekRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[rightWeekRecognizer addTarget:self action:@selector(WeekSwipeRecognizer:)];
[rightWeekRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
}
谁能告诉我为什么会引入这种延迟?
【问题讨论】:
标签: ios uitableview uiviewcontroller storyboard segue