2013-11-23 99 views
0

我有一些奇怪的uitableview行爲 - 我的海關單元格周圍有一些額外的空間,我無法修復。我也可以移動這個空間中的單元格。我附上了幾張照片,因爲我的英文不會讓我更好地解釋。關於這個問題可能會有什麼想法?我可以發佈我的自定義單元的代碼,但它甚至發生在admob添加單元,所以我不確定它與自定義單元有關。strage uitableview單元格行爲:查看單元格內的移動

編輯:增加了對高度

EDIT2代碼:I改變滾動視圖的alloc到

scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width,self.bounds.size.height)];

它固定在細胞的運動。但那條白線還在那裏。

表視圖

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 


    // return (self.tableViewHome.bounds.size.height-49-6-self.tableViewHome.tableHeaderView.bounds.size.height-self.tableViewHome.tableFooterView.bounds.size.height-GAD_SIZE_320x50.height)/3; 
    float height = self.tableViewHome.frame.size.height-self.tableViewHome.tableHeaderView.bounds.size.height-30.0; 

    if (indexPath.item==5) 
    { 
     height=kGADAdSizeBanner.size.height; 
    } 
    else 
    { 
     if (indexPath.item==1 || indexPath.item==3) 
     { 
      height=15.0; 
     } 
     else 
     { 
     if (indexPath.item==0 || indexPath.item==2 || indexPath.item==4) 
     { 
     height=(height-kGADAdSizeBanner.size.height)/3; 
     } 
     } 
    } 

    NSLog(@"Height:%f",height); 

    return height; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
    return 0.1; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
{ 
    return 0.1; 
} 

自定單元

-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) 
    { 

     scrollView = [[UIScrollView alloc] initWithFrame:self.bounds]; 
     scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 

     [scrollView setShowsHorizontalScrollIndicator:NO]; 
     [scrollView setShowsVerticalScrollIndicator:NO]; 


//  NSInteger viewcount= 3; 
//  for(int i = 0; i< viewcount; i++) { 

//  CGFloat x = 2 * self.bounds.size.width; 
     todayView = [HomeTodayView homeTodayView]; 
     todayView.frame = CGRectMake(0, 0,self.bounds.size.width, self.bounds.size.height); 
     todayView.backgroundColor = [UIColor redColor]; 




     avgView = [HomeAvgView homeAvgView]; 
     avgView.frame = CGRectMake(self.bounds.size.width, 0, self.bounds.size.width, self.bounds.size.height); 


      // [[HomeTodayView alloc] initWithFrame: 

     todayView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
     avgView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
     [scrollView addSubview:todayView]; 
     [scrollView addSubview:avgView]; 


     scrollView.contentSize = CGSizeMake(self.bounds.size.width *2, self.bounds.size.height+100); 
     scrollView.pagingEnabled = YES; 
     scrollView.bounces = NO; 


     [self addSubview:scrollView]; 



    } 
    return self; 
} 

Lowest

Max

+0

已分組表格視圖? –

+0

是的。將其更改爲普通,但我沒有看到任何區別 – user2067051

回答

0

試試這個:

[table setSeparatorStyle:UITableViewCellSeparatorStyleNone];

注意: - table =您的tableview名稱。

如果這不起作用,那麼請檢查您的自定義單元格高度和tableView的行高是否相同?

+0

感謝您的建議,但它沒有幫助。我已經添加了我的代碼來設置高度,也許錯誤在那裏? – user2067051

+0

這也是我的建議,所以我可以確保你正在設置cellForRowAtIndexPath以外的地方嗎?即這是整個表格上的一個設置,而不是單個單元格。也許它在viewDidLoad中。 – bobsmells

+0

在viewDidLoad中設置分隔符樣式? – user2067051

相關問題