2014-11-16 174 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

我確實改變了色彩的顏色。問題是檢測正在消失。一旦一切都變成淺色,這些鏈接就不會再點擊了。 –