Это может быть странная проблема, и я надеюсь, что у кого-то это было раньше.Прокрутка TableView влияет на время отклика SegmentControl
Я добавил к моему SegmentControl TableView, используя этот код:
UIView *headerView = [[UIView alloc] init ];
[headerView addSubview:resultsSegment];
self.tableView.tableHeaderView = headerView;
resultsSegment.frame = CGRectMake(45, 123, 250, 40);
[self.tableView addSubview:resultsSegment];
С помощью этих форумов первой три строки сделала Segment часть TableView заголовка, так что он остался на месте для прокрутки. Отлично.
Тем не менее, это отключает возможность щелчка на SegmentControl.
Добавление последней линии, сделанной с возможностью повторного использования.
SegmentControl выполняет отличную прокрутку UNTIL, , тогда становится действительно не отвечающим. Он не вызывает никаких ошибок и в конце концов принимает нажатие пальца, но вы должны нажать его 5/6 раз, прежде чем он переключится.
Если кто-то может пролить некоторый свет на это, что было бы удивительно
Любая дополнительная информация, необходимая, я буду рад предоставить!
EDIT ----
ViewController.h
@interface StdTCPTestViewController : UIViewController <UITableViewDataSource, UITableViewDelegate,UIScrollViewDelegate> {
NSTimer *Timer;
}
@property (nonatomic, strong) NSString *typeOfTest;
@property (nonatomic, strong) NSString *testLocation;
@property (nonatomic, strong) NSString *statusText;
@property (nonatomic, strong) NSString *showResultType;
@property (nonatomic, assign) NSInteger *progressInt;
@property (nonatomic, assign) NSString *testDirection;
@property (strong, nonatomic) IBOutlet UITextView *textView;
@property (strong, nonatomic) IBOutlet UIProgressView *testProgressBar;
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, retain) NSArray *ResultTitles;
@property (nonatomic, retain) NSMutableArray *downloadResults;
@property (nonatomic, retain) NSMutableArray *uploadResults;
@property (strong, nonatomic) IBOutlet UISegmentedControl *resultsSegment;
- (IBAction)resultsSwitch:(id)sender;
Выбрать районы ViewController.m
- (void)viewDidLoad
{
[resultsSegment setTitle:@"Download" forSegmentAtIndex:0]; // Sets the title for the 1st segment button
[resultsSegment setTitle:@"Upload" forSegmentAtIndex:1]; // Sets the title for the 2nd segment button
[super viewDidLoad];
// UIView *headerView = [[UIView alloc] init ];
// [headerView addSubview:resultsSegment];
// self.tableView.tableHeaderView = headerView;
resultsSegment.frame = CGRectMake(45, 123, 250, 40);
[self.tableView addSubview:resultsSegment];
[self APISimpleDemo];
self.navigationItem.title = typeOfTest; // Set viewcontroller title to the type of test it is
}
- (IBAction)resultsSwitch:(id)sender {
if([sender selectedSegmentIndex] == 0){
showResultType = @"download";
[self.tableView reloadData];
}
else {
showResultType = @"upload";
[self.tableView reloadData];
}
}
#pragma mark Table Definitions
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; // Default is 1 if not implemented
{
return 3;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
{
switch (section) {
case 0:
return @"";
break;
case 1:
return @"";
break;
case 2:
return @"";
break;
default:
return @"Section Count Error";
break;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return 35;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
{
switch (section) {
case 0:
return 10;
break;
case 1:
return 22;
break;
case 2:
return 0;
break;
default:
return 22;
break;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
switch (section) {
case 0:
return 3;
break;
case 1:
return 0;
break;
case 2:
return [ResultTitles count];
break;
default:
return 0;
break;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *serverLoc = [tableView dequeueReusableCellWithIdentifier:@"speedCell"];
switch (indexPath.section) {
case 0:
switch (indexPath.row) {
case 0:
serverLoc.textLabel.text = @"Test location:";
serverLoc.detailTextLabel.text = testLocation;
break;
case 1:
serverLoc.textLabel.text = @"Status:";
serverLoc.detailTextLabel.text = statusText;
break;
case 2:
serverLoc.textLabel.text = @"Progress";
serverLoc.detailTextLabel.text = [NSString stringWithFormat:@"%ld%%", (long)progressInt];
break;
}
break;
case 2:
if ([showResultType isEqual:@"download"]) {
serverLoc.textLabel.text = [self.ResultTitles objectAtIndex:indexPath.row];
serverLoc.detailTextLabel.text = [self.downloadResults objectAtIndex:indexPath.row];
break;
}
else {
serverLoc.textLabel.text = [self.ResultTitles objectAtIndex:indexPath.row];
serverLoc.detailTextLabel.text = [self.uploadResults objectAtIndex:indexPath.row];
break;
}
break;
default:
break;
}
return serverLoc;
}
поставить код на github, и я буду рад исправить это. –
Я не смогу выпустить весь код, однако я обновляю свой OP с более подробной информацией за несколько часов. Спасибо –
@eddieios OP обновлен моим кодом, дайте мне знать, если вам нужно больше –