2014-11-16 180 views
1

我正在尝试使用基于textview内容的textview获取动态tableviewcell。它确实展开并完成了这项工作,但是当我滚动时,检测结束并且textview的字体颜色采用了浅色的颜色.PBB代码和屏幕截图。UItextView字体颜色自动更改为色调颜色

ViewController.m

#import "ViewController.h" 
#import "CustomCellTableViewCell.h" 

@interface ViewController() 

@property(nonatomic, strong)NSArray *data; 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.data = [NSArray arrayWithObjects:@"ONe is here wihth some thins www.google.com",@"Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com",@"ONe is here wihth some thins www.google.com",@"Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com",@"ONe is here wihth some thins www.google.com",@"Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com,Two with soe phone numbers like 002-092-98-283 and link http://google.com", nil]; 


    // self.tableView.estimatedRowHeight = 100; 


    self.tableView.rowHeight = UITableViewAutomaticDimension; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [self.data count]; 
} 

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier: 
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls) 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellID = @"CustomCell"; 

    CustomCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; 

    if (!cell) { 
     cell = [[CustomCellTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; 
    } 
    cell.header.text = @"This is a header"; 
    cell.cutomTextview.text = [self.data objectAtIndex:indexPath.row]; 


    return cell; 
} 
@end 

CustomTableViewcell.h

#import <UIKit/UIKit.h> 

@interface CustomCellTableViewCell : UITableViewCell 
@property (weak, nonatomic) IBOutlet UITextView *cutomTextview; 
@property (weak, nonatomic) IBOutlet UITextView *header; 

@end 

Initial launch detecting links

Post scrolling not detection Settings in the storyboard

+0

我有同样的问题,因为我将文本分配给viewWillAppear中的textView。我通过从viewWillApppear中删除分配并将其添加到ViewDidLoad来解决了问题。我认为你在这里有同样的问题,因为你在这行中的文本分配给cellForRowAtIndexPath中的textView cell.cutomTextview.text = [self.data objectAtIndex:indexPath.row]; 。我建议你只在文本为空时才设置文本。在使用cell.cutomTextview.text.length – Sawsan

回答

1

它正在更改字体颜色,因为您已启用'检测:链接,电话号码'。

您可以从Storyboard中取消选择,也可以将UITextview的色调更改为某种其他颜色(blackColor)。

+0

分配之前添加检查但是,我需要检测发生。 –

+0

比改变UITextview的色调颜色。 –

+0

我确实改变了色彩的颜色。问题是检测正在消失。一旦一切都变成浅色,这些链接就不会再点击了。 –